2023年5月6日
摘要: 3.6 #include<bits/stdc++.h>using namespace std; int main(){ int i,t,k,a[3]={0}; for(int i=2;i<1000;i++) { t=0;k=i; while(k) { a[t++]=k%10; k/=10; } if 阅读全文
posted @ 2023-05-06 13:33 临江柔 阅读(4) 评论(0) 推荐(0) 编辑
  2023年5月5日
摘要: 3.4回文数 方法1: 这个数据范围是很小的了,即便是从1遍历到256*256然后再判段每个数的位数才256*256*5时间复杂度,很小的也就6*10^6左右,然后判断前后是否对称即可; 方法2:这是比较简单的方法,从1-256平方,然后判断每个数是否对称即可,不会爆int。 #include<bi 阅读全文
posted @ 2023-05-05 11:10 临江柔 阅读(12) 评论(0) 推荐(0) 编辑
  2023年5月4日
摘要: 3.3自守数 #include<bits/stdc++.h>using namespace std; int main(){ long long mul,n,k,a,b; for(int i=0;i<100000;i++) { for(mul=i,k=1;(mul/=10)>0;k*=10); a= 阅读全文
posted @ 2023-05-04 13:25 临江柔 阅读(10) 评论(0) 推荐(0) 编辑
  2023年4月28日
摘要: 3.2亲密数 思路很简单,先遍历1-3000,把因子算一下,加一下,然后再算和的质因数和,看是否相等即可,时间复杂度不是很高 流程也很简单 #include<bits/stdc++.h>using namespace std; int f(int x)//求一个数的因子和 { int sum=0; 阅读全文
posted @ 2023-04-28 11:42 临江柔 阅读(12) 评论(0) 推荐(0) 编辑
  2023年4月27日
摘要: 3.1完数 #include<bits/stdc++.h>using namespace std;int n; int f(int x){ int sum=0; for(int i=2;i<n/i;i++)//可以缩短时间复杂度 { if(x%i==0)sum+=i; } return sum;} 阅读全文
posted @ 2023-04-27 12:36 临江柔 阅读(10) 评论(0) 推荐(0) 编辑
  2023年4月26日
摘要: 2.11换分币 相当于x张10,y张5,z张1,10x+5y+z=50; #include<bits/stdc++.h>using namespace std;int main(){ for(int i=0;i<=5;i++) { for(int j=0;j<=10;j++) { if(i*10+j 阅读全文
posted @ 2023-04-26 16:27 临江柔 阅读(10) 评论(0) 推荐(0) 编辑
  2023年4月25日
摘要: 2.9设汉王的失算 这道题非常的简单,直接从2的0次方加到2的63次方即可 #include<bits/stdc++.h>using namespace std; int main(){ double ans=0; for(int i=0;i<64;i++) { ans+=pow(2,i); } c 阅读全文
posted @ 2023-04-25 19:07 临江柔 阅读(22) 评论(0) 推荐(0) 编辑
  2023年4月24日
摘要: 2.8 猜数牌 基本框架 for(int i=1;i<=13;i++)//循环13次,每次将一张牌放进盒子 { int n=1; do //内循环找盒子,将i号牌放入 { //如果盒子非空,继续找下一个盒子 //如果盒子空,判断盒子序号和牌序号是否相同,相同则存入 }while(n<=i); } d 阅读全文
posted @ 2023-04-24 12:08 临江柔 阅读(15) 评论(0) 推荐(0) 编辑
  2023年4月21日
摘要: 2.7爱因斯坦的数学题 一个循环解决 #include<iostream>using namespace std;int main(){ for(int i=7;i<10000;i+=7) { if(i%2==1&&i%3==2&&i%5==4&&i%6==5) { cout<<i<<endl; } 阅读全文
posted @ 2023-04-21 10:12 临江柔 阅读(10) 评论(0) 推荐(0) 编辑
  2023年4月20日
摘要: 2.5出售金鱼 我们可以反着来,不断加上1/i条,再乘以i 得到一个公式,n=(n*i+1)/(i-1) 一共要算4次 #include<iostream>using namespace std;int main(){ double n=11; for(int i=5;i>=2;i--) { n=( 阅读全文
posted @ 2023-04-20 12:52 临江柔 阅读(17) 评论(0) 推荐(0) 编辑