01:求平均年龄
#include "iostream"
#include "math.h"
#include "iomanip"
using namespace std;
int main()
{
int count;
cin>>count;
int num[100];
int sum=0;
for(int i=0;i>num[i];
sum+=num[i];
}
cout<
02:财务管理
#include "iostream"
#include "math.h"
#include "iomanip"
using namespace std;
int main()
{
float num[12];
float sum=0;
for(int i=0;i<12;i++)
{
cin>>num[i];
sum+=num[i];
}
cout<
03:均值
#include "iostream"
#include "math.h"
#include "iomanip"
using namespace std;
int main()
{
int count;
cin>>count;
float num;
float sum=0;
for(int i=0;i>num;
sum+=num;
}
cout<
04:求整数的和与均值
#include "iostream"
#include "math.h"
#include "iomanip"
using namespace std;
int main()
{
int count;
cin>>count;
int num;
int sum=0;
for(int i=0;i>num;
sum+=num;
}
cout<
05:最高的分数
#include "iostream"
#include "math.h"
#include "iomanip"
using namespace std;
int main()
{
int count;
cin>>count;
int num;
int max=0;
for(int i=0;i>num;
if(max
06:整数序列的元素最大跨度值
#include "iostream"
#include "math.h"
#include "iomanip"
using namespace std;
int main()
{
int count;
cin>>count;
int num;
int min=1000;
int max=0;
for(int i=0;i>num;
if(maxnum)
min=num;
}
cout<
07:奥运奖牌计数
#include "iostream"
#include "math.h"
#include "iomanip"
using namespace std;
int main()
{
int count;
cin>>count;
int a,b,c;
int gold=0,sliver=0,cotton=0;
for(int i=0;i>a>>b>>c;
gold+=a;
sliver+=b;
cotton+=c;
}
cout<
08:多边形内角和
#include "iostream"
#include "math.h"
#include "iomanip"
using namespace std;
int main()
{
int count;
cin>>count;
int sum=0,num;
for(int i=0;i>num;
sum+=num;
}
cout<<(count-2)*180-sum ;
return 0;
}
09:奇数求和
#include "iostream"
#include "math.h"
#include "iomanip"
using namespace std;
int main()
{
int m,n,temp,sum=0;
cin>>m>>n;
if(m%2==0)
temp=m+1;
else
temp=m;
while(temp<=n)
{
sum+=temp;
temp+=2;
}
cout<
10:满足条件的数累加
#include "iostream"
#include "math.h"
#include "iomanip"
using namespace std;
int main()
{
int m,n,temp,sum=0;
cin>>m>>n;
for(int i=m;i<=n;i++)
{
if(i%17==0)
sum+=i;
}
cout<
11:整数的个数
#include "iostream"
#include "math.h"
#include "iomanip"
using namespace std;
int main()
{
int count,num;
cin>>count;
int time1=0,time5=0,time10=0;
for(int i=0;i>num;
if(num==1)
time1++;
if(num==5)
time5++;
if(num==10)
time10++;
}
cout<
12:与指定数字相同的数的个数
#include "iostream"
#include "math.h"
#include "iomanip"
using namespace std;
int main()
{
int N,m,num;
cin>>N>>m;
int time=0;
for(int i=0;i>num;
if(num==m)
time++;
}
cout<
13:乘方计算
#include "iostream"
#include "math.h"
#include "iomanip"
using namespace std;
int main()
{
int a,n;
cin>>a>>n;
int num=1;
for(int i=0;i
14:人口增长问题
#include "iostream"
#include "math.h"
#include "iomanip"
using namespace std;
int main()
{
int a;
int n;
cin>>a>>n;
double num=(double)a;
for(int i=0;i
15:银行利息
#include "iostream"
#include "math.h"
#include "iomanip"
using namespace std;
int main()
{
int R,M,Y;
cin>>R>>M>>Y;
double num=(double)M;
for(int i=0;i
16:买房子
#include "iostream"
#include "math.h"
#include "iomanip"
using namespace std;
int main()
{
int N,K;
cin>>N>>K;
int count=0;
double money=200;
double earn=0;
while(earn20)//不判断可能会超时
break;
earn=count*N;
//cout<20)
cout<<"Impossible";
else
cout<
17:菲波那契数列
#include "iostream"
#include "math.h"
#include "iomanip"
using namespace std;
int main()
{
int num1=1,num2=1;
int k;
cin>>k;
if(k<=2)
cout<<"1";
else{
for(int i=0;i
18:鸡尾酒疗法
#include "iostream"
#include "math.h"
#include "iomanip"
using namespace std;
int main()
{
int count;
cin>>count;
double num[21];
int num1,num2;
for(int i=0;i>num1>>num2;
num[i]=(double)num2/num1;
}
for(int i=0;i0.05)
cout<<"better"<
#include "iostream"
#include "math.h"
#include "iomanip"
using namespace std;
int main()
{
double x,y;
int num;
int count;
double sum=0;
cin>>count;
for(int i=0;i>x>>y>>num;
sum+=2*(sqrt(pow(x,2)+pow(y,2))/50)+num*1.5;
}
cout<
#include "iostream"
#include "math.h"
#include "iomanip"
using namespace std;
int main()
{
double h;
cin>>h;
double h10;
double hsum=0;
for(int i=0;i<10;i++)
{
if(i!=9){
hsum+=h;
h=h/2;
hsum+=h;}
else{
hsum+=h;
h=h/2;
h10=h;
}
}
cout<
#include "iostream"
#include "math.h"
#include "iomanip"
/*
64位机下 int 4字节 ,long int 8字节
*/
using namespace std;
int main()
{
long int num;//这里用int会Output Limit Exceeded
cin>>num;
if(num==1)
{
cout<<"End";
}else{
while(num!=1){
if(num%2==0)
{
num=num/2;
cout<
#include "iostream"
using namespace std;
int main()
{
int num[12];
for(int i=0;i<12;i++)
{
cin>>num[i];
}
int money=300;
int store=0;
int flag=true;
for(int i=0;i<12;i++)
{
if(money-num[i]>=0)
{
store+=(money-num[i])/100*100;
money=money-(money-num[i])/100*100-num[i]+300;
//cout<
#include "iostream"
using namespace std;
int main()
{
int m,n,num[100]={0};
cin>>m>>n;
for(int i=0;i>num[i];
}
int count=0;
for(int i=0;i
#include "iostream"
using namespace std;
int main()
{
int n;
cin>>n;
int num1,num2;
int time=0,temp=0;
for(int i=0;i>num1>>num2;
if(num1>=90&&num1<=140&&num2>=60&&num2<=90)
{
temp++;
}else
{
temp=0;
}
if(time
#include "iostream"
using namespace std;
/*
七进制和九进制都是三位数,说明该数十进制范围是81~342
整数部分,(123)十进制==(234)七进制
竖除法,逆序取余
7 |123
------
7 | 17 - 4 左边为商 右边为余数
-----
7| 2 - 3
----
7| 0 - 2
*/
int get7(int num)//3位数
{
int num1=0,num2=0,num3=0;
num3=num%7;
num=num/7;
num2=num%7;
num=num/7;
num1=num;
return num1*100+num2*10+num3;
}
int get9(int num)//3位数
{
int num1=0,num2=0,num3=0;
num3=num%9;
num=num/9;
num2=num%9;
num=num/9;
num1=num;
return num1*100+num2*10+num3;
}
int getBack(int num)//3位数
{
int num1=0,num2=0,num3=0;
num1=num%10;
num=num/10;
num2=num%10;
num=num/10;
num3=num;
return num1*100+num2*10+num3;
}
int main()
{
for(int i=81;i<=342;i++)
{
//cout<
#include "iostream"
using namespace std;
int main()
{
int count;
cin>>count;
int num=0;
int n;
for(int i=0;i>n;
int d1=n%10;
int d2=(n%100)/10;
int d3=(n%1000)/100;
int d4=n/1000;
// cout<0)
num++;
}
cout<
#include "iostream"
using namespace std;
int main()
{
double sn=0;
int K;
cin>>K;
int count=1;
while(sn<=K)
{
sn+=1/(double)count;
count++;
}
cout<<--count;
return 0;
}
#include "iostream"
using namespace std;
int main()
{
int num;
cin>>num;
while(num>=10)
{
cout<
#include "iostream"
using namespace std;
int main()
{
string str;
cin>>str;
bool isZero=false;
bool flag=false;
if(str=="0")
isZero=true;
if(str.at(0)=='-')
{
cout<<"-";
flag=true;
}
bool zeroF=true;
int index=0;
if(flag)
index++;
for(int i=0;i
#include "iostream"
#include "math.h"
using namespace std;
int main()
{
string str;
int k;
cin>>str>>k;
int sum=0;
int count=0;
for(int i=0;i
#include "iostream"
using namespace std;
void process(bool flag[],int k,int M)
{
for(int i=0;i>M>>N;
bool flag[M];
for(int i=0;i
#include "iostream"
#include "iomanip"
using namespace std;
int main() {
float p = 1, q = 2, sum = 0;
int N;
cin >> N;
for(int i=0;i
#include "iostream"
#include "iomanip"
using namespace std;
int main() {
float sum = 0;
int N;
cin >> N;
for(int i=1;i<=N;i++)
{
//1/1 - 1/2 + 1/3 - 1/4 + 1/5 - 1/6 + 1/7 - 1/8 + ... + (-1)n-1·1/n
if(i%2==1)
sum += 1/(float)i;
else
sum -= 1/(float)i;
}
cout<
#include "iostream"
#include "iomanip"
using namespace std;
int getFactorial(int k)
{
int result = 1;
for(int i=1;i<=k;i++)
{
result*=i;
}
return result;
}
int main() {
int sum = 0;
int N;
cin >> N;
for(int i=1;i<=N;i++)
{
sum+=getFactorial(i);
}
/*N 取值范围是2~11 因此sum最大值为43954713,在int的范围内*/
cout<
#include "iostream"
#include "iomanip"
using namespace std;
double getFac(double n)
{
if(n==1)
return n;
return n*getFac(n-1);
}
int main(void)
{
double n,e=1;
cin>>n;
for(int i=1;i<=n;i++)
{
e+=1/getFac(i);
}
cout<
#include "iostream"
#include "iomanip"
using namespace std;
int main(void)
{
float x;
int n;
float sum = 1;
cin>>x>>n;
for(int i=1;i<=n;i++)
{
sum=sum*x+1;
}
cout<
#include "iostream"
#include "iomanip"
using namespace std;
int main(void)
{
int M,N,X;
cin>>M>>N>>X;
//初始状态
int fight = N;
int current_M = 0;
while(1)
{
if(X*fight >= M)
{
X-=(M+fight-1)/fight;
current_M+=M;
}//循环结束条件:能量不够补充,说明战斗结束
else
{
break;
}
//参与战斗
fight += M / fight;
current_M = 0;
}
cout<
#include "iostream"
using namespace std;
//注意这道题的样例输入的错误了,没有总次数,输入只有两行
int main(void)
{
int n,C;
cin>>n;
for(int i=n;i>=0;i--){
cin>>C;
if (n == 0) {
cout << 0;
} else {
//最后一项为常数常数的导数为0且不输出
if(i!=0) {
//数字之间有空格
if(i==1)
cout << C*i;
else
cout << C*i<<" ";
}
}
}
}
#include "iostream"
using namespace std;
bool have7(int num)
{
int temp;
while(num)
{
temp = num%10;
num = num/10;
if(temp==7)
{
return true;
}
}
return false;
}
bool divBy7(int num)
{
if(num%7==0)
return true;
else
return false;
}
int main(void)
{
int result=0;
int n;
cin>>n;
for(int i=1;i<=n;i++)
{
if(!have7(i)&&!divBy7(i)) {
result += i * i;
cout<
#include "iostream"
using namespace std;
int get1Count(int num)
{
int temp;
int count = 0;
while(num)
{
temp = num%10;
num = num/10;
if(temp==1)
{
count++;
}
}
return count;
}
int main(void)
{
int result=0;
int num;
cin>>num;
for(int i=1;i<=num;i++)
{
result+=get1Count(i);
}
cout<
#include "iostream"
using namespace std;
int get2Count(int num)
{
int temp;
int count = 0;
while(num)
{
temp = num%10;
num = num/10;
if(temp==2)
{
count++;
}
}
return count;
}
int main(void)
{
int result=0;
int num1,num2;
cin>>num1>>num2;
for(int i=num1;i<=num2;i++)
{
result+=get2Count(i);
}
cout<
#include "iostream"
using namespace std;
int main()
{
int width,height,full;
char shape;
cin>>height>>width>>shape>>full;
if(full)
{
for(int i=0;i
#include "iostream"
#include "math.h"
using namespace std;
bool isPrime(int num)
{
for(int i=2;i<=sqrt(num);i++)
{
if(num%i==0)
return false;
}
return true;
}
int main()
{
int num;
cin>>num;
//从小到大找,最后输出num/i,如果从大到小找输出i会超时
for(int i=2;i<=sqrt(num);i++)
{
if(num%i==0&&isPrime(i))
{
cout<
#include "iostream"
#include "math.h"
using namespace std;
/*质数定义为在大于1的自然数中,除了1和它本身以外不再有其他因数的数称为质数。*/
bool isPrime(int num)
{
if(num == 2)
return true;
int tmp = sqrt(num);
for(int i=2;i<=tmp;i++)
{
if(num%i == 0)
{
return false;
}
}
return true;
}
int main()
{
int n;
cin>>n;
int count = 0;
for(int i=2;i<=1000000000;i++)
{
if(isPrime(i))
{
count++;
}
if(count>=n) {
cout<
#include "iostream"
#include "math.h"
using namespace std;
int step[10001];//step[i]存储第i天总共获取的金币数
int getCoins(int num)
{
int coin = 1;
step[1] = 1;
int index = 2;
while(index<=num)
{
coin++;
for(int j=1;j<=coin;j++)
{
//动态规划的思想
step[index]=step[index-1]+coin;
index++;
}
}
return step[num];
}
int main()
{
int num;
cin>>num;
cout<