C++-蓝桥杯-[T1~T3][结果填空题][2015真题][水题]

T1.求a^2+b^2+c^2=1000正整数解

 1 #include <cstdio>
 2 int main(){
 3     for(int a=1;;a++)
 4         for(int b=a;b<=33;b++)
 5             for(int c=b;c<=33;c++)
 6                 if(a*a+b*b+c*c==1000)
 7                     if(a==6&&b==8&&c==30)continue;
 8                     else {
 9                         printf("%d\n",a);
10                         return 0;
11                     }
12 }

T2. 星系炸弹

 1 #include <bits/stdc++.h>
 2 using namespace std;
 3 int main(){
 4     //2014.11.09+21=2014.11.30
 5     //2014.11.30+31=2014.12.31
 6     //2014.12.31+365=2015.12.31
 7     //2015.12.31+365=2016.12.31
 8     //cout<<(21+31+365+365)+31+29+31+30+31+30+31+5<<endl;
 9     puts("2017-08-05");
10     return 0;
11 }

T3.神奇的数字

 1 #include <bits/stdc++.h>
 2 using namespace std;
 3 int vis[10];
 4 int fill(int x){
 5     int res=0;
 6     for(;x;x/=10,res++)vis[x%10]=1;
 7     return res;
 8 }
 9 bool ok(){
10     int res=0;
11     for(int i=0;i<10;i++)res+=vis[i];
12     return res==10;
13 }
14 int main(){
15     for(int ans=1;ans<100;ans++){
16         memset(vis,0,sizeof(vis));
17         int a=fill(ans*ans*ans);
18         int b=fill(ans*ans*ans*ans);
19         if(a==4&&b==6&&ok()){
20             cout<<ans<<endl;
21             return 0;
22         }
23     }
24 }

 

posted @ 2020-03-08 17:28  墨鳌  阅读(192)  评论(0编辑  收藏  举报