信息学奥赛一本通算法(C版)基础算法高精度计算
- 格式:doc
- 大小:17.00 KB
- 文档页数:3
⼀本通⽹站练习⽬录及AC 代码(基础篇⼰完结)信息学奥赛⼀本通信息学奥赛⼀本通第⼀部分:C++语⾔第⼀部分:C++语⾔第⼀章 C++语⾔⼊门第⼀章 C++语⾔⼊门:⼊门测试题⽬#include<iostream>using namespace std;int main(){int a,b;cin>>a>>b;cout<<a+b;return 0;}点击查看AC 代码:Hello,World!#include<iostream>using namespace std;int main(){cout<<"Hello,World!";return 0;}点击查看AC 代码:输出第⼆个整数#include<iostream>using namespace std;int main(){int a,b,c;cin>>a>>b>>c;cout<<b;return 0;}点击查看AC 代码:对齐输出#include<iostream>#include<bits/stdc++.h>using namespace std;int main(){int a,b,c;cin>>a>>b>>c;cout<<fixed <<setw(8)<<a<<' ';cout<<fixed <<setw(8)<<b<<' ';cout<<fixed <<setw(8)<<c;return 0;}点击查看AC 代码:字符三⾓形#include<iostream>using namespace std;int main(){char ch;cin>>ch;cout<<" "<<ch<<'\n';cout<<" "<<ch<<ch<<ch<<'\n';cout<<ch<<ch<<ch<<ch<<ch<<'\n';return 0;}点击查看AC 代码:地球⼈⼝承载⼒估计#include<cstdio>int main(){int a,b,x,y;double z;scanf("%d %d %d %d",&x,&a,&y,&b);z=(a*x-b*y)/(a-b);printf("%.2f",z);return 0;}点击查看AC 代码第⼆章 顺序结构程序设计第⼆章 顺序结构程序设计第⼀节 运算符和表达式第⼀节 运算符和表达式:A+B 问题#include<iostream>using namespace std;int main(){int a,b;cin>>a>>b;cout<<a+b;return 0;}点击查看AC 代码:计算(a+b)×c 的值#include<iostream>using namespace std;int main(){int a,b,c;cin>>a>>b>>c;cout<<(a+b)*c<<endl;return 0;}点击查看AC 代码:计算(a+b)/c 的值#include<iostream>using namespace std;int main(){int a,b,c;cin>>a>>b>>c;cout<<(a+b)/c;return 0;}点击查看AC 代码:带余除法int main(){int bcs,cs,s,ys;cin>>bcs>>cs;s=bcs/cs;ys=bcs%cs;cout<<s<<' '<<ys;return 0;}点击查看AC 代码:计算分数的浮点数值#include<iostream>#include<iomanip>using namespace std;int main(){double a,b;cin>>a>>b;cout<<fixed <<setprecision(9)<<a/b;return 0;}点击查看AC 代码第⼆节 常量和变量第⼆节 常量和变量:甲流疫情死亡率#include<iostream>#include<iomanip>using namespace std;int main(){int a,b;cin>>a>>b;cout<<fixed <<setprecision(3)<<100.0*b/a<<'%'<<endl;return 0;}点击查看AC 代码:计算多项式的值#include<iostream>#include<iomanip>using namespace std;int main(){double x,a,b,c,d;cin>>x>>a>>b>>c>>d;cout<<fixed <<setprecision(7)<<x*(x*(a*x+b)+c)+d;return 0;}点击查看AC 代码:温度表达转化#include<iostream>#include<iomanip>using namespace std;int main(){double f;cin>>f;cout<<fixed <<setprecision(5)<<(f-32)/9*5;return 0;}点击查看AC 代码:与圆相关的计算#include<iomanip>int main(){double r,pi=3.14159,d,c,s;cin>>r;d=r*2;c=pi*2*r;s=pi*r*r;cout<<fixed <<setprecision(4)<<d;cout<<' '<<fixed <<setprecision(4)<<c;cout<<' '<<fixed <<setprecision(4)<<s;return 0;}点击查看AC 代码:计算并联电阻的阻值#include<iostream>using namespace std;#include<iomanip> //int main(){float r1,r2;cin>>r1>>r2;cout<<fixed <<setprecision(2)<<r1*r2/(r1+r2);return 0;}点击查看AC 代码第三节 标准数据类型第三节 标准数据类型:整型数据类型存储空间⼤⼩#include<iostream>using namespace std;//#include<iomanip> fixed<<setprecisionint main(){cout<<sizeof (int )<<' '<<sizeof (short )<<endl;return 0;}点击查看AC 代码:浮点型数据类型存储空间⼤⼩#include<iostream>using namespace std;//#include<iomanip> fixed<<setprecisionint main(){cout<<sizeof (float )<<' '<<sizeof (double )<<endl;return 0;}点击查看AC 代码:其他数据类型存储空间⼤⼩#include<iostream>using namespace std;//#include<iomanip> fixed<<setprecisionint main(){cout<<sizeof (bool )<<' '<<sizeof (char )<<endl;return 0;}点击查看AC 代码:浮点数向零舍⼊#include<iostream>using namespace std;//#include<iomanip> fixed<<setprecisionint main(){float a;int b;cin>>a;b=int (a);cout<<b<<endl;return 0;}点击查看AC 代码:打印ASCII 码#include<iostream>using namespace std;//#include<iomanip> fixed<<setprecisionint main(){char ch;cin>>ch;cout<<ch+0<<endl;return 0;}点击查看AC 代码:打印字符#include<iostream>using namespace std;//#include<iomanip> fixed<<setprecisionint main(){int n;cin>>n;cout<<char (n)<<endl;return 0;}点击查看AC 代码:整型与布尔型的转换#include<iostream>using namespace std;int main(){int n;bool bl;cin>>n;bl=bool (n);n=bl;cout<<n<<endl;return 0;}点击查看AC 代码:Hello,World!的⼤⼩#include<iostream>using namespace std;int main(){cout<<sizeof ("Hello, World!");return 0;}点击查看AC 代码第四节 数据输⼊输出第四节 数据输⼊输出:保留3位⼩数的浮点数#include<iostream>#include<iomanip>using namespace std;int main(){float a;cin>>a;cout<<fixed <<setprecision(3)<<a<<endl;return 0;}点击查看AC 代码:保留12位⼩数的浮点数#include<iostream>#include<iomanip>using namespace std;int main(){double a;cin>>a;cout<<fixed <<setprecision(12)<<a<<endl;return 0;}点击查看AC 代码:空格分隔输出#include<iostream>#include<iomanip>using namespace std;int main(){char a;int b;float c;double d;cin>>a>>b>>c>>d;cout<<a<<' '<<b<<' '<<fixed <<setprecision(6)<<c<<' '<<d<<endl; return 0;}点击查看AC 代码:输出浮点数#include<cstdio>using namespace std;int main(){double a;scanf("%lf",&a);printf("%lf\n%.5lf\n%e\n%g",a,a,a,a);return 0;}点击查看AC 代码:字符菱形#include<iostream>using namespace std;int main(){int flag=0,m=3;char ch;cin>>ch;for (int i=1;i<=2*m-1;i++){int tmpi=i>m?2*m-i:i;for (int j=1;j<m+1-tmpi;j++)cout<<' ';for (int j=1;j<=2*tmpi-1;j++)cout<<ch;cout<<'\n';}return 0;}点击查看AC 代码第五节 顺序结构实例第五节 顺序结构实例:计算浮点数相除的余#include<iostream>using namespace std;#include<cmath>int main(){double a,b;cin>>a>>b;int k=floor(a/b);cout<<a-k*b;return 0;}点击查看AC代码:计算球的体积#include<iostream>#include<iomanip>using namespace std;const double pi=3.14;int main(){double r;cin>>r;cout<<fixed<<setprecision(2)<<4*pi/3*r*r*r<<endl;return0;}点击查看AC代码:反向输出⼀个三位数#include<iostream>using namespace std;int main(){int a;cin>>a;do{cout<<a%10;a/=10;}while(a);return0;}点击查看AC代码:⼤象喝⽔查#include<iostream>using namespace std;const double pi=3.14159;int main(){int h,r;cin>>h>>r;cout<<int(20000/(pi*r*r*h))+1;return0;}点击查看AC代码:计算线段长度#include<iostream>#include<cmath>#include<iomanip>using namespace std;int main(){double xa,ya,xb,yb;cin>>xa>>ya>>xb>>yb;cout<< fixed<<setprecision(3)<<sqrt((xa-xb)*(xa-xb)+(ya-yb)*(ya-yb)); return0;}点击查看AC代码:计算三⾓形⾯积#include<iostream>#include<cmath>#include<iomanip>using namespace std;double jl(double x1,double y1,double x2,double y2){return sqrt((x1-x2)*(x1-x2)+(y2-y1)*(y2-y1));}int main(){double x1,y1,x2,y2,x3,y3,p,a,b,c,s;cin>>x1>>y1>>x2>>y2>>x3>>y3;a=jl(x1,y1,x2,y2);b=jl(x2,y2,x3,y3);c=jl(x1,y1,x3,y3);p=(a+b+c)/2;s=sqrt(p*(p-a)*(p-b)*(p-c));cout<<fixed <<setprecision(2)<<s<<endl; return 0;}点击查看AC 代码:等差数列末项计算#include<iostream>using namespace std;int main(){int a1,a2,n;cin>>a1>>a2>>n;cout<<a1+(n-1)*(a2-a1);return 0;}点击查看AC 代码:A×B 问题#include<iostream>using namespace std;#include<cmath>int main(){int a,b;cin>>a>>b;cout<<1ll*a*b;return 0;}点击查看AC 代码:计算2的幂#include<iostream>using namespace std;int main(){int n;cin>>n;long long m=1;for (int i=1;i<=n;i++)m*=2;cout<<m<<endl;return 0;}点击查看AC 代码:苹果和⾍⼦#include<iostream>using namespace std;int main(){int n,x,y,m;cin>>n>>x>>y;m=n-1.0*y/x;if (m<0)m=0;cout<<m<<endl;return 0;}点击查看AC 代码第三章 程序的控制结构第三章 程序的控制结构第⼀节 if 选择结构第⼀节 if 选择结构:判断数正负#include<iostream>using namespace std;int main(){int n;cin>>n;if (n>0)cout<<"positive";else cout<<(n==0?"zero":"negative")<<endl;}点击查看AC代码:输出绝对值#include<iostream>#include<iomanip>using namespace std;int main(){double a;cin>>a;cout<<fixed<<setprecision(2)<<(a>0?a:a*(-1)); return0;}点击查看AC代码:奇偶数判断#include<iostream>using namespace std;int main(){long a;cin>>a;cout<<(a%2?"odd":"even");return0;}点击查看AC代码:奇偶ASCII值判断#include<cstdio>int main(){if(getchar()%2)printf("YES");else printf("NO");return0;}点击查看AC代码:整数⼤⼩⽐较#include<iostream>using namespace std;int main(){long long a,b;cin>>a>>b;if(a>b)cout<<'>';else cout<<(a==b?'=':'<');return0;}点击查看AC代码:判断是否为两位数#include<iostream>using namespace std;int main(){short n;cin>>n;if(n>=10&&n<=99)cout<<1;else cout<<0;return0;}点击查看AC代码:收集瓶盖赢⼤奖#include<iostream>using namespace std;int main(){double a,b;if (a>=10||b>=20)cout<<1;else cout<<0;return 0;}点击查看AC 代码:判断⼀个数能否同时被3和5整除#include<iostream>using namespace std;int main(){long long n;cin>>n;if (n%3==0&&n%5==0)cout<<"YES"; else cout<<"NO";return 0;}点击查看AC 代码:判断能否被3,5,7整除#include<iostream>using namespace std;int main(){long long n;cin>>n;if (n%3==0&&n%5==0)cout<<"YES"; else cout<<"NO";return 0;}点击查看AC 代码:有⼀门课不及格的学⽣#include<iostream>using namespace std;int main(){long long n;cin>>n;if (n%3==0&&n%5==0)cout<<"YES"; else cout<<"NO";return 0;}点击查看AC 代码第⼆节 switch 语句第⼆节 switch 语句:晶晶赴约会#include<iostream>using namespace std;int main(){int n;cin>>n;if (n==1||n==3||n==5)cout<<"NO"; else cout<<"YES";return 0;}点击查看AC 代码:骑车与⾛路#include<iostream>using namespace std;int main(){double x,b,w;cin>>x;b=27+23+x/3;w=x/1.2;if (w>b)cout<<"Bike";else cout<<(w==b?"All":"Walk");return0;}点击查看AC代码:分段函数#include<iostream>#include<iomanip>using namespace std;int main(){float x,y;cin>>x;if(x<5)y=2.5-x;else if(x>=10)y=x/2-1.5;else y=2-1.5*(x-3)*(x-3);cout<<fixed<<setprecision(3)<<y;return0;}点击查看AC代码:计算邮资#include<iostream>using namespace std;int main(){int n,p;char a;cin>>n>>a;p=n>1000?(8+(n-1000+499)/500*4):8;p+=(a=='y'?5:0);cout<<p;return0;}点击查看AC代码:最⼤数输出#include<iostream>using namespace std;int main(){int a,b,c,maxn;cin>>a>>b>>c;maxn=a;if(maxn<b)maxn=b;if(maxn<c)maxn=c;cout<<maxn;return0;}点击查看AC代码:三⾓形判断#include<iostream>using namespace std;int main(){int a,b,c;cin>>a>>b>>c;if(a+b>c&&a+c>b&&b+c>a)cout<<"yes";else cout<<"no";return0;}点击查看AC代码:判断闰年#include<iostream>using namespace std;int main(){int n;cin>>n;cout<<(n%100==0&&n%400!=0||n%4!=0?'N':'Y'); return0;}点击查看AC代码:点和正⽅形的关系#include<iostream>using namespace std;int main(){long long x,y;cin>>x>>y;if((-1<=x)&&(x<=1)&&(-1<=y)&&(y<=1))cout<<"yes";else cout<<"no";return0;}点击查看AC代码:简单计算器#include<iostream>using namespace std;int main(){int a,b;char c;cin>>a>>b>>c;switch(c){case'+':cout<<a+b;break;case'-':cout<<a-b;break;case'*':cout<<a*b;break;case'/':if(b==0)cout<<"Divided by zero!";else cout<<a/b;break;default:cout<<"Invalid operator!";}return0;}点击查看AC代码:求⼀元⼆次⽅程#include<iostream>#include<cmath>#include<iomanip>using namespace std;int main(){double a,b,c;cin>>a>>b>>c;double det;det=b*b-4*a*c;if(det<-1e-12){cout<<"No answer!";}else{if(fabs(det)<1e-12){cout<<"x1=x2="<<fixed<<setprecision(5)<<-b/(2*a);}else{double x1,x2;x1=(-b+sqrt(det))/2/a;x2=(-b-sqrt(det))/2/a;if(x1<x2){cout<<"x1="<<fixed<<setprecision(5)<<x1<<";x2="<<fixed<<setprecision(5)<<x2; }else{cout<<"x1="<<fixed<<setprecision(5)<<x2<<";x2="<<fixed<<setprecision(5)<<x1; }}}return0;}点击查看AC代码第四章 循环结构的程序设计第四章 循环结构的程序设计第⼀节 for 语句第⼀节 for 语句:求平均年龄#include<iostream>#include<iomanip>using namespace std;int main(){int n,b[1000],sum=0;cin>>n;for (int i=1;i<=n;i++){cin>>b[i];sum+=b[i];}cout<<fixed <<setprecision(2)<<1.0*sum/n; return 0;}点击查看AC 代码:均值#include<iostream>#include<iomanip>using namespace std;int main(){int n;cin>>n;double a[1000],sum=0;for (int i=1;i<=n;i++){cin>>a[i];sum+=a[i];}cout<<fixed <<setprecision(4)<<sum/n; return 0;}点击查看AC 代码:求整数的和与均值#include<iostream>#include<iomanip>using namespace std;int main(){int n,a[10001],sum=0;cin>>n;for (int i=1;i<=n;i++){cin>>a[i];sum+=a[i];}cout<<sum<<' '<<fixed <<setprecision(5)<<1.0*sum/n; return 0;}点击查看AC 代码:最⾼的分数#include<iostream>using namespace std;int main(){int n,a[1000],maxn=-1;cin>>n;for (int i=1;i<=n;i++){cin>>a[i];if (a[i]>maxn)maxn=a[i];}cout<<maxn;return 0;}点击查看AC代码:最⼤跨度值#include<iostream>using namespace std;int main(){int n,a[1001],maxn=-1,minn=1001;cin>>n;for(int i=1;i<=n;i++){cin>>a[i];if(minn>a[i])minn=a[i];if(maxn<a[i])maxn=a[i];}cout<<maxn-minn;return0;}点击查看AC代码:奥运奖牌计数#include<iostream>using namespace std;int main(){int n,a,b,c,suma=0,sumb=0,sumc=0,sum;cin>>n;for(int i=1;i<=n;i++){cin>>a>>b>>c;suma+=a,sumb+=b,sumc+=c;}sum=suma+sumb+sumc;cout<<suma<<''<<sumb<<''<<sumc<<''<<sum; return0;}点击查看AC代码:奇数求和#include<iostream>using namespace std;int main(){int m,n,sum=0;cin>>m>>n;for(int i=m;i<=n;i++)if(i%2)sum+=i;cout<<sum;return0;}点击查看AC代码:满⾜条件的数累加#include<iostream>using namespace std;int main(){int m,n,sum=0;cin>>m>>n;for(int i=m;i<=n;i++)if(!(i%17))sum+=i;cout<<sum;return0;}点击查看AC代码:整数的个数#include<iostream>using namespace std;int main(){int n,m,sum1=0,sum5=0,sum10=0;cin>>n;for(int i=1;i<=n;i++){cin>>m;if(m==1)sum1++;if(m==5)sum5++;if(m==10)sum10++;}cout<<sum1<<'\n'<<sum5<<'\n'<<sum10; return0;}点击查看AC代码:与指定数字相同的数的个数#include<iostream>using namespace std;int main(){int n,x,m,sum=0;cin>>n>>m;for(int i=1;i<=n;i++){cin>>x;if(x==m)sum++;}cout<<sum;return0;}点击查看AC代码:乘⽅计算#include<iostream>using namespace std;int main(){int a,n,ans=1;cin>>a>>n;for(int i=1;i<=n;i++)ans*=a;cout<<ans;return0;}点击查看AC代码:⼈⼝增长#include<iostream>#include<iomanip>using namespace std;int main(){double a,n,ans=1;cin>>a>>n;for(int i=1;i<=n;i++)ans*=1.001;cout<<fixed<<setprecision(4)<<ans*a; return0;}点击查看AC代码:菲波那契数#include<iostream>using namespace std;int main(){int k,a[50];cin>>k;a[1]=1,a[2]=1;for(int i=3;i<=k;i++)a[i]=a[i-1]+a[i-2];cout<<a[k];return0;}点击查看AC代码:鸡尾酒疗法#include<iostream>#include<cmath>#include<cstdio>using namespace std;int main(){int n;double z,y,z1,y1,jd=1e-6;double new1,old;cin>>n;cin>>z>>y;old=y/z; //这个计算要放在循环外⾯才⾏for(int i=0;i<n-1;i++){cin>>z1>>y1;new1=y1/z1;old=y/z; //这个计算要放在循环外⾯才⾏if(new1-old>0.05-jd) cout<<"better"<<endl;else if((old-new1)>0.05-jd) cout<<"worse"<<endl;else cout<<"same"<<endl;}return0;}点击查看AC代码:救援#include<iostream>#include<cmath>using namespace std;int main(){double n,a,b,c,sum=0;int s;cin>>n;for(int i=1;i<=n;i++){cin>>a>>b>>c;sum+=sqrt(a*a+b*b)/25+1.5*c;}s=ceil(sum);cout<<s;return0;}点击查看AC代码:津津的储蓄计划#include<iostream>using namespace std;int main(){int a[13],b=0,sum=0,i;for(i=1;i<=12;i++)cin>>a[i];for(i=1;i<=12;i++){b+=300-a[i];if(b<0)break;sum+=b/100*100;b%=100;}if(i==13)cout<<1.2*sum+b;else cout<<-i;return0;}点击查看AC代码:药房管理#include<iostream>using namespace std;int main(){int n,m,a,ans=0;cin>>n>>m;for(int i=1;i<=m;i++){cin>>a;if(n>=a)n-=a;else ans++;}cout<<ans;return0;}点击查看AC代码:正常⾎压#include<iostream>using namespace std;int main(){int n,a,b,ans=0,maxn=-1;cin>>n;for(int i=1;i<=n;i++){cin>>a>>b;if(90<=a&&a<=140&&60<=b&&b<=90){ ans++;if(ans>maxn)maxn=ans;}else ans=0;}cout<<maxn;return0;}点击查看AC代码:统计满⾜条件的4位数#include<iostream>using namespace std;int main(){int n,a,a1,a2,a3,a4,ans=0;cin>>n;for(int i=1;i<=n;i++){cin>>a;a1=a%10;a2=a/10%10;a3=a/100%10;a4=a/1000;if(a1>a2+a3+a4)ans++;}cout<<ans;return0;}点击查看AC代码:求分数序列和#include<iostream>#include<iomanip>using namespace std;int main(){float n,p,q,tmp,ans=0;p=1,q=2,ans=q/p;cin>>n;for(int i=2;i<=n;i++){tmp=q;q+=p;p=tmp;ans+=q/p;}cout<<fixed<<setprecision(4)<<ans; return0;}点击查看AC代码:计算分数加减表达式的值#include<iostream>#include<iomanip>using namespace std;int main(){int n;double s;cin>>n;for(int i=1;i<=n;i++)s+=(i%2?1.0/i:-1.0/i);cout<<fixed<<setprecision(4)<<s; return0;}点击查看AC代码:余数相同问题#include<iostream>using namespace std;int main(){int a,b,c,ans;cin>>a>>b>>c;for(int i=2;i<=a||a<=b||a<=c;i++)if(a%i==b%i&&a%i==c%i){ans=i;break;}cout<<ans;return0;}点击查看AC代码:分苹果#include<iostream>using namespace std;int main(){int n;cin>>n;cout<<n*(n+1)/2;return0;}点击查看AC代码:求⼩数的某⼀位#include<iostream>using namespace std;int main(){int a,b,c,ans;cin>>a>>b>>c;a%=b;for(int i=1;i<=c;i++){ans=a*10/b;a=a*10%b;}cout<<ans;return0;}点击查看AC代码:计算星期⼏#include<iostream>#include<cmath>#include<cstdio>using namespace std;int main(){int a,b,xh=0,sum=1;//循环int yx;//有效的次⽅cin>>a>>b;a%=7;for (int i=1;i<=b;i++){sum=sum*a;if ((sum%7==a)&&i>1){xh=i-1;break ;}}if (xh>1){yx=int (pow(a,b%xh))%7;}else{yx=sum%7;}switch (yx){case 1:cout<<"Monday";break ; case 2:cout<<"Tuesday";break ; case 3:cout<<"Wednesday";break ; case 4:cout<<"Thursday";break ; case 5:cout<<"Friday";break ; case 6:cout<<"Saturday";break ; case 0:cout<<"Sunday";break ; }return 0;}点击查看AC 代码:幂的末尾#include<iostream>#include<iomanip>using namespace std;int main(){int a,b,ans;cin>>a>>b;ans=a%1000;for (int i=1;i<b;i++)ans=ans*a%1000;cout<<setfill('0')<<setw(3)<<ans; return 0;}点击查看AC 代码第⼆节 while 语句第⼆节 while 语句:球弹跳⾼度的计算#include<iostream>using namespace std;int main(){double h0,n=10,s,h;cin>>h0;s=-h0,h=h0;for (int i=1;i<=n;i++){s+=h*2;h/=2;}cout<<s<<'\n'<<h;return 0;}点击查看AC 代码:⾓⾕猜想#include<iostream>using namespace std;int main(){int n;cin>>n;while(n!=1){if(n%2){cout<<n<<"*3+1=";n=n*3+1;cout<<n<<'\n';}else{cout<<n<<'/'<<2<<'=';n/=2;cout<<n<<'\n';}}cout<<"End";return0;}点击查看AC代码:级数求和#include<iostream>using namespace std;int main(){double k,ans=0;long long n=1;cin>>k;while(ans<=k+(1e-16)){ans+=1.0/n++;}cout<<n-1;return0;}点击查看AC代码:分离整数的各个数#include<iostream>using namespace std;int main(){int n;cin>>n;cout<<n%10;n/=10;while(n){cout<<''<<n%10;n/=10;}return0;}点击查看AC代码:数字反转#include<iostream>using namespace std;int main(){//余数⾃带符号,如(-31)%10=-1 int n,ans=0;cin>>n;while(n){ans=ans*10+n%10;n/=10;}cout<<ans;return0;}点击查看AC代码#include<iostream>using namespace std;int main(){int n,k,ans=0;cin>>n>>k;if (n%19)cout<<"NO";else{while (n){if (n%10==3)ans++;n/=10;}if (ans==k)cout<<"YES";else cout<<"NO";}return 0;}点击查看AC 代码第三节 do-while 语句第三节 do-while 语句:球弹跳⾼度的计算//1085:球弹跳⾼度的计算#include<iostream>using namespace std;int main(){double h,ans,i;cin>>h;ans=-h;i=0;do{ans+=h*2;h/=2;i++;}while (i<10);cout<<ans<<endl<<h;return 0;}点击查看AC 代码:⾓⾕猜想//1086:⾓⾕猜想#include<iostream>using namespace std;int main(){int n;cin>>n;do{cout<<n;if (n%2){cout<<"*3+1=";n=n*3+1;}else{cout<<"/2=";n/=2;}cout<<n<<endl;}while (n!=1);cout<<"End"<<endl;return 0;}点击查看AC 代码:级数求和#include<iostream> using namespace std;int main(){double s=0;int k,n=0;cin>>k;do{n++;s+=1.0/n;}while(s-k<1e-12);cout<<n;return0;}点击查看AC代码:分离整数的各个数//1088:分离整数的各个数#include<iostream> using namespace std;int main(){int n;cin>>n;do{cout<<n%10<<'';n/=10;}while(n);return0;}点击查看AC代码:数字反转//1089:数字反转#include<iostream> using namespace std;int main(){int n,ans=0,f=1;cin>>n;if(n<0)f=-1,n=-n;do{ans=ans*10+n%10; n/=10;}while(n);ans*=f;cout<<ans;return0;}点击查看AC代码:含k个3的数//1090:含k个3的数#include<iostream> using namespace std;int main(){int n,k;cin>>n>>k;do{if(n%10==3)k--;n/=10;}while(n);if(k)cout<<"NO";else cout<<"YES"; return0;}点击查看AC代码第四节循环嵌套using namespace std;long long a[100];int main(){int n;long long sum=0;cin>>n;a[0]=1;for(int i=1;i<=n;i++){a[i]=a[i-1]*i ;sum+=a[i];}cout<<sum;return0;}点击查看AC代码:求出e的值#include<iostream>#include<iomanip>using namespace std;double a[1000];int main(){double n, sum=1;cin>>n;a[0]=1;for(int i=1;i<=n;i++){a[i]=a[i-1]/i ;sum+=a[i];}cout<<fixed<<setprecision(10)<<sum; return0;}点击查看AC代码:计算多项式的值#include<iostream>#include<cmath>#include<iomanip>using namespace std;int main(){double x,b;int n;cin>>x>>n;b=(pow(x,n+1)-1)/(x-1);cout<<fixed<<setprecision(2)<<b; return0;}点击查看AC代码:与7⽆关的数#include<iostream>using namespace std;bool cont(int n){while(n){if(n%10==7)return true;n/=10;}return false;}int main(){int n,sum=0;cin>>n;for(int i=1;i<=n;i++)if(!cont(i)&&(i%7))sum+=i*i;cout<<sum;return0;}。
信息学奥赛⼀本通(C++)在线评测系统——基础(⼀)C++语⾔——1074:津津的储蓄计划时间限制: 1000 ms 内存限制: 65536 KB提交数: 11986 通过数: 5727【题⽬描述】津津的零花钱⼀直都是⾃⼰管理。
每个⽉的⽉初妈妈给津津300元钱,津津会预算这个⽉的花销,并且总能做到实际花销和预算的相同。
为了让津津学习如何储蓄,妈妈提出,津津可以随时把整百的钱存在她那⾥,到了年末她会加上20%还给津津。
因此津津制定了⼀个储蓄计划:每个⽉的⽉初,在得到妈妈给的零花钱后,如果她预计到这个⽉的⽉末⼿中还会有多于100元或恰好100元,她就会把整百的钱存在妈妈那⾥,剩余的钱留在⾃⼰⼿中。
例如11⽉初津津⼿中还有83元,妈妈给了津津300元。
津津预计11⽉的花销是180元,那么她就会在妈妈那⾥存200元,⾃⼰留下183元。
到了11⽉⽉末,津津⼿中会剩下3元钱。
现在请你根据2004年1⽉到12⽉每个⽉津津的预算,判断会不会出现这种情况。
如果不会,计算到2004年年末,妈妈将津津平常存的钱加上20%还给津津之后,津津⼿中会有多少钱。
【输⼊】包括12⾏数据,每⾏包含⼀个⼩于350的⾮负整数,分别表⽰1⽉到12⽉津津的预算。
【输出】只包含⼀个整数。
如果储蓄计划实施过程中出现某个⽉钱不够⽤的情况,输出-X,X表⽰出现这种情况的第⼀个⽉;否则输出到2004年年末津津⼿中会有多少钱。
【输⼊样例】29023028020030017034050908020060【输出样例】-7【样例2】输⼊:29023028020030017033050908020060输出:1580【来源】NO代码#include <stdio.h>int main (){int month[13],meiyuelinghuaqian[13],meiyueshengqian[13],mamacunqian=0;meiyuelinghuaqian[1]=300;for(int i=1;i<=12;i++){scanf("%d",&month[i]);if((meiyuelinghuaqian[i]-month[i]>0)&&((meiyuelinghuaqian[i]-month[i])/100==0)){meiyueshengqian[i]=meiyuelinghuaqian[i]-month[i];}if((meiyuelinghuaqian[i]-month[i]>0)&&((meiyuelinghuaqian[i]-month[i])/100>0)){meiyueshengqian[i]=meiyuelinghuaqian[i]-month[i]-int((meiyuelinghuaqian[i]-month[i])/100)*100; mamacunqian+=int((meiyuelinghuaqian[i]-month[i])/100)*100;}if(meiyuelinghuaqian[i]-month[i]<0){printf("-%d",i);return 0;}meiyuelinghuaqian[i+1]=300+meiyueshengqian[i];}int x=int(mamacunqian*1.2+meiyueshengqian[12]);printf("%d",x);return 0;}。
信奥赛一本通—c 语言运算符和表达式(原创版)目录1.信奥赛一本通介绍2.C 语言运算符分类3.算术运算符4.关系运算符5.逻辑运算符6.位运算符7.赋值运算符8.其他运算符9.表达式的概念和分类10.表达式的求值正文【信奥赛一本通介绍】《信奥赛一本通》是一本针对信息学奥林匹克竞赛(NOI)的辅导教材,内容包括计算机编程基础、数据结构与算法、组合数学等。
本书旨在帮助学生提高编程能力,培养逻辑思维,以便在信息学竞赛中取得优异成绩。
【C 语言运算符分类】C 语言中的运算符可以分为以下几类:1.算术运算符2.关系运算符3.逻辑运算符4.位运算符5.赋值运算符6.其他运算符【算术运算符】算术运算符包括加(+)、减(-)、乘(*)、除(/)、取模(%)等,它们用于对数值进行加减乘除等运算。
【关系运算符】关系运算符包括大于(>)、小于(<)、大于等于(>=)、小于等于(<=)、等于(==)、不等于(!=)等,它们用于比较两个数值的大小或相等关系。
【逻辑运算符】逻辑运算符包括与(&&)、或(||)、非(!)等,它们用于进行逻辑运算,如判断条件是否成立等。
【位运算符】位运算符包括按位与(&)、按位或(|)、按位异或(^)、左移(<<)、右移(>>)等,它们用于对二进制数进行位运算。
【赋值运算符】赋值运算符包括等号(=)和赋值运算符(+=、-=、*=、/=、%=),它们用于给变量赋值或将一个值赋给一个表达式。
【其他运算符】其他运算符包括括号(()、[]、{})、逗号(,)、点(.)等,它们用于表示运算顺序和数据结构。
【表达式的概念和分类】表达式是计算机程序设计中用于表示数值、变量、运算符等组成的式子。
根据运算符的类型,表达式可以分为以下几类:1.算术表达式:包含算术运算符的表达式。
2.关系表达式:包含关系运算符的表达式。
3.逻辑表达式:包含逻辑运算符的表达式。
《信奥赛一本通—c 语言运算符和表达式》随着信息技术的不断发展,编程语言作为计算机与人交流的桥梁,也日益受到重视。
在众多编程语言中,C语言因其简洁、高效的特点备受青睐,成为不少软件开发者的首选。
在C语言中,运算符和表达式是非常基础且重要的概念,对于初学者来说,掌握此部分知识是建立扎实的编程基础的关键。
在本篇文章中,我将从简单的运算符介绍开始,逐步深入到表达式的计算与运用,帮助我更全面、深入地理解C语言运算符和表达式这一主题。
1. 运算符的基本概念我们来了解C语言中常见的运算符,包括赋值运算符、算术运算符、关系运算符、逻辑运算符等。
其中,赋值运算符用于将右侧的数值或表达式赋给左侧的变量;算术运算符包括加法、减法、乘法、除法、取模等,用于表示基本的数学运算;关系运算符用来比较两个值之间的关系,通常返回真或假;逻辑运算符用于连接或改变关系表达式的值,包括与、或、非等。
2. 运算符的优先级和结合性在实际编程中,运算符的优先级和结合性是至关重要的。
优先级决定了表达式中运算符的执行顺序,而结合性则决定了相同优先级的运算符在没有括号的情况下如何组合。
在C语言中,乘法运算符的优先级高于加法运算符,因此在计算表达式时会先执行乘法运算。
3. 表达式的计算与运用除了掌握各类运算符的基本概念外,更重要的是理解如何运用这些运算符来构建各种复杂的表达式。
在实际编程中,我们经常需要进行变量赋值、数学运算、逻辑比较等操作,这就需要灵活运用C语言的运算符和表达式来实现。
总结回顾通过本文的阅读与学习,相信我已经对C语言运算符和表达式有了更深入的了解。
我掌握了C语言中常见的运算符,包括赋值运算符、算术运算符、关系运算符和逻辑运算符,对其基本概念有了清晰的认识。
我了解了运算符的优先级和结合性的重要性,能够在编程中灵活运用这些知识。
通过学习如何构建复杂的表达式,我对C语言运算符和表达式的应用有了更深层次的理解。
个人观点和理解对我来说,C语言运算符和表达式是建立编程基础的重要一环。
【题目描述】
设S是一个具有n个元素的集合,S= a1,a2,……,an ,现将S划分成k个满足下列条件的子集合S1,S2,……,Sk且满足:
1.Si≠∅
2.Si∩Sj=∅ (1≤i,j≤k,i≠j)
3.S1∪S2∪S3∪…∪Sk=S
则称S1,S2,……,Sk是集合S的一个划分。
它相当于把S集合中的n个元素a1,a2,……,an放入k个(0<k≤n<30)无标号的盒子中,使得没有一个盒子为空。
请你确定n个元素a1,a2,……,an放入k个无标号盒子中去的划分数S(n,k)。
【输入】
给出n和k。
【输出】
n个元素a1,a2,……,an放入k个无标号盒子中去的划分数S(n,k)。
【输入样例】
10 6
【输出样例】
22827
思路:计算 C(n,k) ,直接递归即可
【源程序】
#include<iostream>
using namespace std;
long long calculate(long long n,long long k)
{
if(n<k||k==0)
return 0;
if(n==k||k==1)
return 1;
return calculate(n-1,k-1)+k*calculate(n-1,k);
}
int main()
{
long long n,k;
cin>>n>>k;
cout<<calculate(n,k)<<endl;
return 0;
}。
第一章算法基础篇学习过程序设计的人对算法这个词并不陌生,从广义上讲,算法是指为解决一个问题而采用的方法和步骤;从程序计设的角度上讲,算法是指利用程序设计语言的各种语句,为解决特定的问题而构成的各种逻辑组合。
我们在编写程序的过程就是在实施某种算法,因此程序设计的实质就是用计算机语言构造解决问题的算法。
算法是程序设计的灵魂,一个好的程序必须有一个好的算法,一个没有有效算法的程序就像一个没有灵魂的躯体。
算法具有五个特征:1、有穷性:一个算法应包括有限的运算步骤,执行了有穷的操作后将终止运算,不能是个死循环;2、确切性:算法的每一步骤必须有确切的定义,读者理解时不会产生二义性。
并且,在任何条件下,算法只有唯一的一条执行路径,对于相同的输入只能得出相同的输出。
如在算法中不允许有“计算8/0”或“将7或8与x相加”之类的运算,因为前者的计算结果是什么不清楚,而后者对于两种可能的运算应做哪一种也不知道。
3、输入:一个算法有0个或多个输入,以描述运算对象的初始情况,所谓0个输入是指算法本身定义了初始条件。
如在5个数中找出最小的数,则有5个输入。
4、输出:一个算法有一个或多个输出,以反映对输入数据加工后的结果,这是算法设计的目的。
它们是同输入有着某种特定关系的量。
如上述在5个数中找出最小的数,它的出输出为最小的数。
如果一个程序没有输出,这个程序就毫无意义了;5、可行性:算法中每一步运算应该是可行的。
算法原则上能够精确地运行,而且人能用笔和纸做有限次运算后即可完成。
如何来评价一个算法的好坏呢?主要是从两个方面:一是看算法运行所占用的时间;我们用时间复杂度来衡量,例如:在以下3个程序中,(1)x:=x+1(2)for i:=1 to n dox:=x+1(3)for i:=1 to n dofor j:=1 to n dox:=x+1含基本操作“x增1”的语句x:=x+1的出现的次数分别为1,n和n2则这三个程序段的时间复杂度分别为O(1),O(n),O(n2),分别称为常量阶、线性阶和平方阶。
信息学奥赛NOIP系列课程(三阶段)第一阶段C++语言及数据结构与算法基础课本:1、信息学奥赛一本通+训练指导教程C++版第五版--2017年出版(两本)第1部分C++语言(50课时)适于:零基础的初中或高中的学生,当然有C语言或scratch、Python语言基础更好授课:相关内容讲授+实例+题目现堂训练(每次课2-3题,题目较大可能是1题)第1章C++语言入门(2-3课时)第2章顺序结构程序设计(6课时)第3章程序控制结构(3课时)NOIP2017复赛普及组第1题成绩https:///problem-12334.htmlNOIP2018复赛普及组第1题标题统计方法一https:///problem-12393.htmlNOIP1996普及组第1题https:///WDAJSNHC/article/details/83513564https:///yuyanggo/article/details/47311665第4章循环结构(5课时)NOIP2018复赛普及组第1题标题统计方法二https:///problem-12393.htmlNOIP2016复赛普及组第1题买铅笔https:///problem-12121.htmlNOIP2015复赛普及组第1题金币/ch0105/45/NOIP2002复赛普及组第1题级数求和/ch0105/27/NOIP2013复赛普及组第1题计数问题https:///problem-11005.html?tdsourcetag=s_pcqq_aiomsgNOIP2012复赛普及组第1题质因数分解/ch0105/43/NOIP2011复赛普及组第1题数字反转/ch0105/29/NOIP2010复赛普及组第1题数字统计https:///problem-10012.htmlNOIP1999普及组第1题Cantor表/ch0201/8760/https:///problemnew/show/P1014NOIP1997普及组第1题棋盘问题https:///problemnew/show/P1548NOIP1995普及组复赛第1题https:///secret_zz/article/details/76862335https:///WDAJSNHC/article/details/83513896NOIP1997普及组第2题数字三角形https:///ber_bai/article/details/76722379第5章数组(9-10课时)NOIP2014复赛普及组第1题珠心算测验https:///problem-12091.htmlNOIP2009复赛普及组第1题多项式输出/ch0113/39/NOIP2006复赛普及组第1题明明的随机数/ch0110/09/NOIP2005复赛普及组第1题陶陶摘苹果/ch0106/02/NOIP2004复赛普及组第1题不高兴的津津/ch0109/03/NOIP2003年普及组第1题乒乓球/ch0113/37/NOIP1998年普及组第1题三连击(枚举)https:///problemnew/show/P1008NOIP1995普及组复赛第2题方阵填数https:///WDAJSNHC/article/details/79381876NOIP1996普及组第2题格子问题https:///WDAJSNHC/article/details/79381843?utm_source=blogxgwz5NOIP2016复赛普及组第2题回文日期https:///problem-12122.htmlhttps:///problemnew/show/P2010NOIP2015普及组第2题P2670扫雷游戏/ch0108/14/https:///problemnew/show/P2670https:///problem-12105.htmlNOIP2012普及组第2题_P1076寻宝/ch0112/06/https:///problemnew/show/P1076第6章函数(5课时)NOIP2008复赛普及组第1题ISBN号码/ch0107/29/NOIP2000提高组第1题P1017进制转换https:///problemnew/show/P1017NOIP2000普及组第1题计算器的改良https:///problemnew/show/P1022https:///yuyanggo/article/details/47856785https:///u012773338/article/details/41749421NOIP2018普及组第2题龙虎斗https:///problemnew/show/P5016https:///problem-12394.html机器翻译【1.12编程基础之函数与过程抽象07】Noip2010提高组第1题/ch0112/07/Vigenère密码【1.12编程基础之函数与过程抽象08】Noip2012提高组第1题/ch0112/08/笨小猴【1.9编程基础之顺序查找06】NOIP2008提高组第1题/ch0109/06/第7章文件和结构体(5课时)NOIP2011复赛提高组第1题铺地毯/ch0109/14/NOIp2008提高组第2题火柴棒等式https:///problemnew/show/P1149https:///Mr_Doublerun/article/details/52589778第8章指针及其应用(8课时)第9章C++实用技巧与模版库(5课时)NOIP2007复赛普及组第1题奖学金/ch0110/04/NOIP2017复赛普及组第2题图书管理员(STL、排序)https:///problem-12335.htmlhttps:///problemnew/show/P3955NOIP1999普及组第2题回文数https:///problemnew/show/P1015***模拟NOIP2017年提高组第2题时间复杂度(模拟)https:///problem-12333.htmlhttps:///problemnew/show/P3952NOIP2011普及组第3题P1309瑞士轮(模拟、快拍、归并排序)/ch0401/4363/https:///problemnew/show/P1309NOIP2018复赛普及组第3题摆渡车(模拟)https:///problem-12395.htmlhttps:///problemnew/show/P5017NOIP2016普及组第3题海港(port)--枚举https:///problemnew/show/P2058NOIP2006年提高组第3题P1065作业调度方案(模拟)https:///problemnew/show/P1065NOIP2013提高组第4题P1969积木大赛(模拟贪心)https:///problem-12071.htmlhttps:///problemnew/show/P1969NOIP2014提高组第4题P2038无线网络发射器选址(模拟)https:///problemnew/show/P2038第2部分NOIP基础算法(39课时)第1章高精度计算(2-3课时)【例1.6】回文数(Noip1999):8088/problem_show.php?pid=1309NOIP2003普及组第4题P1045麦森数(分治、高精度运算)https:///problemnew/show/P1045NOIP2005普及组第4题P1050循环(高精度运算、数论、快速幂) https:///problemnew/show/P1050第2章数据排序(3课时)NOIP2014复赛普及组第1题珠心算测验https:///problem-12091.html第3章递推算法(2-3课时)1314:【例3.6】过河卒(Noip2002):8088/problem_show.php?pid=1314NOIP2011普及组第4题P1310表达式的值(栈、表达式计算、递推) https:///problemnew/show/P1310NOIP2011提高组第6题P1315观光公交(递推分析、贪心)https:///problemnew/show/P1315第4章递归算法(2-3课时)【例4.6】数的计数(Noip2001普及组第1题):8088/problem_show.php?pid=1316第5章搜索与回溯算法(2-3课时)NOIP2015day1T3_斗地主P2668斗地主https:///problemnew/show/P2668NOIP2017年普及组第3题棋盘https:///problemnew/show/P3956https:///problem-12336.htmlNOIP2015年提高组第2题P2661信息传递(Tarjen bfs/dfs(图论))https:///problem-12107.htmlhttps:///problemnew/show/P2661NOIP2016年提高组第2题天天爱跑步(Lca/dfs(图论)树结构最近公共祖先)https:///problem-12208.htmlhttps:///problemnew/show/P1600NOIP2000普及组第4题P1019单词接龙(深搜)https:///problemnew/show/P1019NOIP2000年提高组第3题单词接龙(DFS,字符串,模拟)https:///problemnew/show/P1019NOIP2014普及组第4题P2258子矩阵(搜索或dp)https:///problemnew/show/P2258NOIP2018年提高组第3题P5021赛道修建(搜索深度优先搜索)https:///problem-12392.htmlhttps:///problemnew/show/P5021第6章贪心算法(3课时)删数问题(NOIP1994)P1106删数问题https:///problemnew/show/P1106:8088/problem_show.php?pid=1321NOIP2010复赛普及组第2题接水问题/ch0109/15/NOIP1999年提高组第1题导弹拦截https:///problemnew/show/P1020https:///huashanqingzhu/p/6728652.html https:///qq_33927580/article/details/51853345 https:///Darost/article/details/52086240https:///yuyanggo/article/details/48739029NOIP2002提高组第1题均分纸牌P1031均分纸牌https:///problemnew/show/P1031NOIP2007普及组第2题_P1094纪念品分组https:///problem-12007.htmlhttps:///problemnew/show/P1094NOIP2008普及组第2题_P1056排座椅https:///problem-12008.htmlhttps:///problemnew/show/P1056NOIP2012年提高组第2题国王游戏(贪心、排序后列出)https:///problemnew/show/P1080NOIP2013年提高组第2题P1966火柴排队(逆序对、贪心、排序) https:///problem-12083.htmlhttps:///problemnew/show/P1966NOIP2010普及组第4题P1199三国游戏(贪心)https:///problemnew/show/P1199第7章分治算法(3课时)NOIP2001提高组第1题P1024一元三次方程求解/ch0204/7891/https:///problemnew/show/P1024NOIP2011年提高组第2题P1311选择客栈(二分查找)https:///problemnew/show/P1311NOIP2003普及组第4题P1045麦森数(分治、高精度运算)https:///problemnew/show/P1045第8章广度优先搜索算法(2-3课时)NOIP2002年提高组第2题P1032字串变换(BFS,字符串)https:///problemnew/show/P1032NOIP2013提高组第6题P1979华容道(广搜\最短路:图论)https:///problem-12212.htmlhttps:///problemnew/show/P1979第9章动态规划(15课时)第一节动态规划的基本模型1260:【例9.4】拦截导弹(NOIP1999):8088/problem_show.php?pid=1260NOIP2013普及组第3题P1982小朋友的数字https:///problemnew/show/P1982NOIP2003复赛普及组第2题_P1043数字游戏数字游戏(Game.cpp)https:///problemnew/show/P1043NOIP2006年提高组第2题P1064金明的预算方案(资源分配DP,构造) https:///problemnew/show/P1064NOIP2013普及组第3题P1982小朋友的数字(动态规划、子段和)https:///problemnew/show/P1982NOIP2007普及组第3题P1095守望者的逃离(动态规划或枚举)https:///problemnew/show/P1095NOIP2009普及组第4题P1070道路游戏(动态规划)https:///problemnew/show/P1070NOIP2004年提高组第3题P1091合唱队形(子序列DP)https:///problemnew/show/P1091第二节背包问题NOIP2018提高组第2题货币系统https:///problem-12391.htmlNOIP2006普及组第2题_P1060开心的金明题解https:///problemnew/show/P1060NOIP2005普及组第3题P1048采药(0/1背包)/ch0206/1775/https:///problem-12062.htmlhttps:///problemnew/show/P1048NOIP2001普及组第4题P1049装箱问题(0/1背包或枚举)https:///problemnew/show/P1049NOIP2014年提高组第3题P1941飞扬的小鸟(背包DP)https:///problem-12087.htmlhttps:///problemnew/show/P1941第三节动态规划经典题NOIP2000年提高组第2题P1018乘积最大(资源分配DP)https:///problemnew/show/P1018NOIP2000普及组第3题P1018乘积最大(划分动态规划)https:///problemnew/show/P1018NOIP2001年提高组第2题P1025数的划分(资源分配DP,多维状态DP)/ch0206/8787/https:///problemnew/show/P1025NOIP2001年提高组第3题统计单词个数(资源分配DP,字符串) https:///problemnew/show/P1026NOIP2005年提高组第2题P1052过河(子序列DP,贪心优化)https:///problemnew/show/P1052NOIP2010年提高组第2题P1541乌龟棋(动态规划优化)https:///problemnew/show/P1541NOIP2014年提高组第2题P1351联合权值(动态规划搜索图结构树形DP图的遍历遍历(图论),二次展开式)https:///problem-12086.htmlhttps:///problem-12210.htmlhttps:///problemnew/show/P1351NOIP2008普及组第3题P1057传球游戏(动态规划)https:///problemnew/show/P1057NOIP2012普及组第3题摆花(动态规划)https:///problem-12366.htmlhttps:///problemnew/show/P1077NOIP2002普及组第4题P1002过河卒(棋盘动态规划)https:///problemnew/show/P1002NOIP2008年提高组第3题P1006传纸条(多维状态DP动态规划图结构最短路网络流)https:///problem-12110.htmlhttps:///problemnew/show/P1006NOIP2000提高组第4题方格取数(多维状态DP)/ch0206/8786/https:///problem-12186.htmlhttps:///problemnew/show/P1004NOIP2002提高组第4题P1034矩形覆盖(动态规划/贪心/搜索剪枝) /ch0405/1793/https:///problemnew/show/P1034第3部分NOIP数据结构(19课时)第1章栈(3课时)NOIP2011普及组第4题P1310表达式的值(栈、表达式计算、递推) https:///problemnew/show/P1310第2章队列(3-5课时)NOIP2016普及组第3题海港(port)https:///problemnew/show/P2058第3章树(3课时)第一节树的概念第二节二叉树第三节堆及其应用NOIP2015普及组第4题P2672推销员(枚举、堆)https:///problemnew/show/P2672NOIP2001普及组第3题P1030求先序排列(树的遍历)https:///problemnew/show/P1030NOIP2004普及组第3题P1087FBI树(二叉树的遍历)https:///problemnew/show/P1087第4章图论算法(8课时)第一节基本概念第二节图的遍历第三节最短路径算法NOIP2002普及组第3题P1037产生数(最短路、高精度)https:///problemnew/show/P1037NOIP2012普及组第4题P1078文化之旅(搜索、最短路(图论)、动规) https:///problemnew/show/P1078NOIP2009年提高组第3题P1073最优贸易(最短路:图论)https:///problemnew/show/P1073NOIP2001提高组第4题P1027Car的旅行路线(最短路,实数处理)https:///problemnew/show/P1027NOIP2007提高组第4题P1099树网的核(最短路,树的直径)https:///problemnew/show/P1099第四节图的连通性问题第五节并查集NOIP2010年提高组第3题P1525关押罪犯(二分答案或并查集)https:///problemnew/show/P1525NOIP2017提高组第4题P3958奶酪(数据结构树结构并查集)https:///problem-12205.htmlhttps:///problemnew/show/P3958第六节最小生成树第七节拓朴排序与关键路径NOIP2013普及组第4题P1983车站分级(图论、拓扑排序) https:///problemnew/show/P19831390:食物链【NOI2001】:8088/problem_show.php?pid=1390NOIP2004年提高组第2题P1090合并果子(最优哈夫曼树,排序,贪心)https:///problemnew/show/P1090NOIP2013年提高组第3题P1967货车运输(最大生成树,最近公共祖先)https:///problemnew/show/P1967NOIP2018提高组第4题P5022旅行(搜索图结构)https:///problem-12397.htmlhttps:///problemnew/show/P5022NOIP2018提高组第6题P5024保卫王国(图结构)https:///problem-12399.htmlhttps:///problemnew/show/P50242、啊哈!算法--2014-06(35-50小时)第二阶段算法与数据结构提高1、《信息学奥赛一本通·提高篇》(80-100课时,不一定一次都讲完)第一部分基础算法第1章贪心算法NOIP2002提高组第1题P1031均分纸牌(贪心,模拟)https:///problemnew/show/P1031NOIP2010普及组第3题P1158导弹拦截(排序+枚举,贪心)https:///problemnew/show/P1158NOIP2012提高组第6题P1084疫情控制(二分答案,贪心,倍增)https:///problemnew/show/P1084第2章二分与三分NOIP2010年提高组第3题P1525关押罪犯(二分答案或并查集)https:///problemnew/show/P1525NOIP2008提高组第4题P1155双栈排序(枚举,贪心/二分图)https:///problemnew/show/P1155NOIP2015提高组第4题P2678跳石头(二分查找、二分答案)https:///problem-12198.htmlhttps:///problemnew/show/P2678第3章深搜的剪枝技巧NOIP2018普及组第4题对称二叉树(搜索树结构深度优先搜索)https:///problem-12396.htmlhttps:///problemnew/show/P5018NOIP2011年提高组第3题P1312Mayan游戏(深搜、剪支)https:///problemnew/show/P1312NOIP2015年提高组第3题P2668斗地主(分情况,剪枝)https:///problemnew/show/P2668NOIP2003提高组第4题P1041传染病控制(随机贪心/搜索剪枝)https:///problemnew/show/P1041NOIP2004提高组第4题P1092虫食算(搜索搜索与剪枝)https:///problem-12414.htmlhttps:///problemnew/show/P1092第4章广搜的优化技巧NOIP2017年普及组第3题棋盘(搜索搜索与剪枝广度优先搜索)https:///problemnew/show/P3956https:///problem-12336.htmlNOIP2009提高组第4题P1074靶形数独(搜索优化)https:///problemnew/show/P1074NOIP2010提高组第4题P1514引入水域(广搜+动态规划,判断有解和无解)https:///problemnew/show/P1514第二部分字符串算法第1章哈希表第2章KMP算法第3章Trie字典树第4章AC自动机NOIP2005提高组第4题P1054等价表达式(字符串,抽样检测,表达式) /practice/1686/https:///problemnew/show/P1054NOIP2008普及组第4题P1058立体图(字符输出)https:///problemnew/show/P1058NOIP2006普及组第3题P1061Jam的计数法(数学、字符串)https:///problemnew/show/P1061NOIP2007年提高组第2题字符串的展开(字符串模拟)https:///problem-11016.htmlhttps:///problemnew/show/P1098NOIP2003年提高组第2题P1039侦探推理(枚举,模拟,字符串)https:///problemnew/show/P1039NOIP2011普及组第2题_P1308统计单词数/ch0112/05/https:///problemnew/show/P1308第三部分图论第1章最小生成树第2章最短路径NOIP2016年提高组第3题P1850换教室(最短路/Dp)https:///problemnew/show/P1850NOIP2017年提高组第3题P3953逛公园(搜索图结构记忆化搜索最短路)https:///problem-12337.htmlhttps:///problemnew/show/P3953NOIP2014提高组第5题P1351联合权值(遍历,二次展开式)https:///problem-12086.htmlhttps:///problemnew/show/P1351第3章SPFA算法的优化第4章差分约束系统第5章强连通分量第6章割点和桥第7章欧拉回路第四部分数据结构第1章树状数组第2章RMQ问题第3章线段树NOIP2012提高组第5题P1083借教室(枚举、线段树、树状数组、二分) https:///problem-12069.htmlhttps:///problemnew/show/P1083NOIP2017提高组第6题P3960列队(数据结构平衡树线段树)https:///problem-12339.htmlhttps:///problemnew/show/P3960第4章倍增求LCANOIP2015提高组第6题P2680运输计划(Lca或线段树)https:///problem-12213.htmlhttps:///problemnew/show/P2680第5章树链剖分第6章平衡树Treap第五部分动态规划第1章区间类型动态规划NOIP2007年提高组第3题P1005矩阵取数游戏(区间DP,高精度)https:///problemnew/show/P1005第2章树型动态规划NOIP2003年提高组第3题P1040加分二叉树(树,区间DP)https:///problemnew/show/P1040第3章数位动态规划第4章状态压缩类动态规划NOIP2017提高组第5题P3959宝藏(动态规划搜索贪心状态压缩DP枚举)https:///problem-12340.htmlhttps:///problemnew/show/P3959NOIP2016提高组第6题愤怒的小鸟(状态压缩动态规划)https:///problemnew/show/P2831第5章单调队列优化动态规划NOIP2016提高组第5题蚯蚓(单调队列)https:///Mrsrz/p/7517155.htmlhttps:///m0_38083668/article/details/82557281NOIP2017普及组第4题P3957跳房子(数据结构动态规划单调队列队列)https:///problem-12338.htmlhttps:///problemnew/show/P3957第6章利用斜率优化动态规划NOIP2012年提高组第3题P1081开车旅行(离线深搜,动态规划、倍增)https:///problemnew/show/P1081NOIP2015提高组第5题P2679子串(Dp+滚动数组)https:///problemnew/show/P2679第六部分数学基础第1章快速幂第2章素数第3章约数第4章同余问题第5章矩阵乘法第6章组合数学NOIP2009年提高组第2题P1072Hankson的趣味题(初等数论,质因数,组合数学)https:///problemnew/show/P1072NOIP2006提高组第4题P10662^k进制数(动态规划/组合数学,高精度) https:///problemnew/show/P1066NOIP2011提高组第4题P1313计算系数(组合、二项式系数)/practice/4036/https:///problemnew/show/P1313NOIP2016提高组第4题P2822组合数问题(杨辉三角)https:///problemnew/show/P2822第7章博弈论NOIP2004普及组第4题P1088火星人(数学:排列、stl)https:///problemnew/show/P1088NOIP2009普及组第3题P1069细胞分裂(数论)https:///problemnew/show/P1069NOIP2000提高组第1题P1017进制转换(初等代数,找规律)https:///problemnew/show/P1017NOIP2001提高组第1题P1024一元三次方程求解(数学,枚举,实数处理) /ch0204/7891/https:///problemnew/show/P1024NOIP2003普及组第3题P1044栈(数学:卡特兰数)https:///problemnew/show/P1044NOIP2018年提高组第2题货币系统(数论)https:///problem-12391.htmlhttps:///problemnew/show/P5020NOIP2014年普及组复赛第3题螺旋矩阵(数学分析)https:///problem-12341.htmlhttps:///problemnew/show/P2239NOIP2015年普及组第3题求和(数学:数列)https:///problemnew/show/P2671NOIP2004普及组第4题P1088火星人(数学:排列、stl)https:///problemnew/show/P1088NOIP2005普及组第4题P1050循环(高精度运算、数论、快速幂) https:///problemnew/show/P1050NOIP2006普及组第4题P1062数列(数学:进制转换)https:///problemnew/show/P1062NOIP2007普及组第4题P1096$Hanoi$双塔问题(数学、高精度) https:///problemnew/show/P1096NOIP2016普及组第4题P2119魔法阵(数学分析、枚举)https:///problemnew/show/P2119NOIP2002年提高组第3题P1033自由落体(数学,物理,模拟,实数处理) https:///problemnew/show/P1033NOIP2005年提高组第3题P1053篝火晚会(置换群,贪心)https:///problemnew/show/P1053NOIP2012提高组第4题P1082同余方程(数论、递归,扩展欧几里得)https:///problemnew/show/P1082NOIP2011提高组第5题P1314聪明的质监员(部分和优化)/practice/4037/https:///problemnew/show/P1314NOIP2013提高组第5题P1970花匠(序列)https:///problem-12072.htmlhttps:///problemnew/show/P1970NOIP2018提高组第5题P5023填数游戏(DP)https:///problem-12398.htmlhttps:///problemnew/show/P50232、NOIP历年真题讲解(30-50小时)---包括初赛和复赛3、《骗分导论》(推荐指数:5颗星)--电子书(可以作为学习的参考资料)第三阶段算法与数据结构高级专题(选择性学习)1、信息学奥赛之数学专题2、高级数据结构(C++版)3、动态规划专题注:上面的内容也可能要交叉的进行讲解在线题库:1、OpenJudge在线题库/2、信息学奥赛一本通在线评测系统:8088/3、洛谷https:///4、啊哈编程/tiku/5、《信息学奥赛一本通(提高篇)》在线评测OJhttps://loj.ac/注:本系列课程将根据行业发展状况,及时优化调整课程内容,具体课程设置以实际为准。
百度文库 - 让每个人平等地提升自我
1
高精度加法(大位相加)
#include
using namespace std;
int main()
{
char a1[100],b1[100];
int a[100],b[100],c[100];
>
using namespace std;
int main()
{
char n[256],n1[256],n2[256];
int a[256],b[256],c[256];
int lena,lenb,lenc,i;
memset(a,0,sizeof(a));
memset(b,0,sizeof(b));
memset(c,0,sizeof(c));
while(scanf("%s%s",&n1,&n2)!=EOF)//n1为被减数,n2为减数
{
if(strlen(n1)
{
strcpy(n,n1);//将n1数组的值完全赋值给n数组
百度文库 - 让每个人平等地提升自我
2
strcpy(n1,n2);
strcpy(n2,n);//处理被减数和减数时,交换被减数和减数
cout<<"-";//交换了减数和被减数,结果为负数
}
lena=strlen(n1);
lenb=strlen(n2);
for(i=0;i<=lena;i++)
a[lena-i]=(int)(n1[i]-'0');//被减数放入数组a中
for(i=0;i<=lenb;i++)
b[lenb-i]=(int)(n2[i]-'0');//减数放入数组b中
i=1;
while(i<=lena||i<=lenb)
{
if(a[i]{
a[i]+=10;//不够减,那么向高位借1当10
a[i+1]--;
}
c[i]=a[i]-b[i];//对应位相减
i++;
}
lenc=i;
百度文库 - 让每个人平等地提升自我
3
while((c[lenc]==0)&&(lenc>1))
lenc--;//最高位的0不输出
for(i=lenc;i>=1;i--)
cout<
return 0;
}