A double eleven preferential (simple version)
n <= 1e19, 1e9 > 1(8)
https://www.cometoj.com/contest/79/problem/A?problem_id=4198
#include<bits/stdc++.h> using namespace std; int main(){ int t; cin >> t; while(t--) { int cnt1 = 0; int n;cin >> n; int pr[] = {1,11,111,1111,11111,111111,1111111,11111111,111111111}; for(int i = 8; i >= 0; i--) { Chntl + = N / Q [i]; Neither % = Q [i]; } if(cnt1 > 9) cout << "Impossible\n"; else cout << cnt1 << endl; } return 0; }
D version difficulty
https://www.cometoj.com/contest/79/analysis // dm get together online Topic, passing through do not miss
May be assumed that a particular band, 1111111111 ............
This is then converted to decimal number hexadecimal, for example 234--> 2,1,1 (2 * 111 + 1 * 11 + 1)
Hexadecimal digits in the sum of the number of "good number" of need, we will find that when other digits except the last one is greater than 9:00, can be converted to the smaller band
for example 11,0 0 -> 1,0,10,0 10,0,1,0 -> 1,0,0,0,10
then we can as i i th binary, hexadecimal take contribution under this
11,0,0 -> 1,0,10,0 (3 * 11 * 4 = 331 = 14 + 10 * 1) 10,0,1,0 -> 1,0,0,0,10 (10 * 4 + 2 = 421 * 5 + 10 = 15)
will find that when there are more than 9 digits (not the last one) into a smaller band contribution is smaller, so we can have him into smaller therefore, in line with selection greedy nature
Conclusion: when a decimal number is represented by "good number", with the greatest possible "good number" of the current meet said minimum number "good number" spent
B when we are together, concentric
https://www.cometoj.com/contest/79/problem/B?problem_id=4199
#include <bits / STDC ++. H> #define LL Long Long // violence enumerate each coordinate is used as the center can have several points of equal distance from the center, ANS = F + [CNT1] // Each another point as the center point of the array as the distance to the center and then seek a few sort, so the floating point accuracy errors will change the function from the square root can not ll ac
distance // may be obtained by the map memory per ,
a using namespace std; ll dist(ll x1, ll y1, ll x2, ll y2){ return ((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)); } int main(){ int t; t = 1; //cin >> t; while(t--) { int n;cin >> n; int ans = 0; //vector<pair<int, int> > dot(n+1); ll dx[2020], dy[2020]; for(int i = 0; i < n; i++) cin >> dx[i] >> dy[i]; for(int i = 0; i < n; i++) { int x = i; vector<ll> dis; for(int j = 0; j < n; j++){ if(i == j) continue; ll distan = dist(dx[i], dy[i], dx[j], dy[j]); dis.push_back(distan); //cout << "i = " << i << " dis = " << distan << endl << endl; } sort(dis.begin(), dis.end()); ll y = -1; int cnt1 = 1; for(int j = 0; j < n-1; j++){ //cout << dis[j] << " y = " << y << " cnt1 = " << cnt1 << endl << endl; if(dis[j] == y) cnt1++; else { years + = (CNT1 * (cnt1- 1 ) * (cnt1- 2 ) / 6 ); y = tell [j]; CNT1 = 1 ; } } //cout << "ans = " << ans << " cnt1= "<< cnt1<< " f[cnt1]" << f[cnt1] << endl << endl; ans += (cnt1*(cnt1-1)*(cnt1-2)/6); //cout << "!111\n"; } cout << ans << endl; } return 0; }
#include <bits / STDC ++ H.> #define LL Long Long // read the explanations, a case slightly to optimize the using namespace STD; ll dist(ll x1, ll y1, ll x2, ll y2){return ((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));} int main(){ int t; t = 1; while(t--) { int n;cin >> n; int ans = 0; //vector<pair<int, int> > dot(n+1); ll dx[2020], dy[2020]; for(int i = 0; i < n; i++) cin >> dx[i] >> dy[i]; for(int i = 0; i < n; i++) { vector<ll> dis; for(int j = 0; j < n; j++){ dis.push_back(dist(dx[i], dy[i], dx[j], dy[j])); } sort(dis.begin(), dis.end()); for(int j = 0, k; j < n; j = k){ for(k = j; dis[k] == dis[j]; k++); years + = (kj) * (kj- 1 ) * (kj- 2 ) / 6 ; } } cout << ans << endl; } return 0; }