lanqiao 1443 卡片(优化解法)

This commit is contained in:
2025-04-02 20:17:49 +08:00
parent d6da8ac929
commit afc7f65471

19
12lanqiao/test2-2.cpp Normal file
View File

@@ -0,0 +1,19 @@
// lanqiao 1443 卡片(优化解法)
#include<bits/stdc++.h>
using namespace std;
// 优化思路据题意所得一定是1先被消耗完只需考虑1何时消耗完即可
int main(){
int s = 2021;
for(int i = 1; ;i++){
int t = i;
while(t){
if(t%10 == 1) s--;
if(s < 0){
cout << i - 1 << endl;
return 0;
}
t /= 10;
}
}
return 0;
}