1、方程整数解
#include<bits/stdc++.h>
using namespace std;
int main(){
for(int a=1;a<35;a++){
for(int b=1;b<35;b++){
for(int c=1;c<35;c++){
if(a*a+b*b+c*c==1000){
cout<<a<<" "<<b<<" "<<c<<" "<<endl;
}
}
}
}
return 0;
}
答案:10
2、星系炸弹
用excel算的
A1写死为2014-11-9
C1=B1-A1
调整B1直到C1=1000
答案: 2017-08-05
3、奇妙的数字
将平方和立方转换成字符串,拼接字符串,字符串排序,判断字符串是否等于0123456789
#include<bits/stdc++.h>
using namespace std;
string num2str( double i)
{
stringstream ss;
string s;
ss<<i;
ss>>s;
return s;
}
int main(){
for(int a=1;a<10000;a++){
int b=a*a;
int c=a*a*a;
string temp=num2str(b)+num2str(c);
sort(temp.begin(),temp.end());
if(temp=="0123456789"){
cout<<a<<endl;
return 0;
}
}
return 0;
}
答案:69
6、牌型种数
想到的是高中数学题目排列组合的知识
模糊的记得大概是这样
DFS写法
#include<bits/stdc++.h>
using namespace std;
int pais[13];
vector<int> path;
int ans=0;
int countof(vector<int> path,int pai){
int count=0;
for(int i=0;i<path.size();i++){
if(path[i]==pai){
count++;
}
}
return count;
}
void dfs(int n,vector<int>&path){
if(n==0){
ans++;
return;
}
for(int i=0;i<13;i++){
if(countof(path,pais[i])<4){
path.push_back(pais[i]);
dfs(n-1,path);
path.pop_back();
}
}
}
int main(){
for(int i=1;i<=13;i++) {
pais[i-1]=i;
}
dfs(13,path);
cout<<ans<<endl;
}
7、手链样式
8、饮料换购
模拟即可
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
cin>>n;
int res=n;
while(n>=3){
int temp=n/3;
n-=(temp*3);
n+=(temp);
res+=(temp);
}
cout<<res;
}
9、垒骰子
10、