lanqiao 1443 卡片(优化解法)
This commit is contained in:
19
12lanqiao/test2-2.cpp
Normal file
19
12lanqiao/test2-2.cpp
Normal 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;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user