C - Repunit Trio
https://atcoder.jp/contests/abc333/tasks/abc333_c
思路
N=333时候, repunit最长12位,
三重遍历 repunit 做和记录到vector中
最后对vector进行排序,取n值。
Code
https://atcoder.jp/contests/abc333/submissions/48575689
vector<long long> sums; int n; long long get_repunit(int t){ long long val = 1; while(--t){ val *= 10; val += 1; } return val; } int main() { cin >> n; for(int i=1; i<=12; i++){ long long ival = get_repunit(i); for(int j=i; j<=12; j++){ long long jval = get_repunit(j); for(int k=j; k<=12; k++){ long long kval = get_repunit(k); long long ijksum = ival + jval + kval; sums.push_back(ijksum); } } } sort(sums.begin(), sums.end()); cout << sums[n-1] << endl; return 0; }
标签:Trio,val,int,Repunit,abc333,long,repunit From: https://www.cnblogs.com/lightsong/p/17908496.html