03 2015 档案
摘要:#include using namespace std; #define Maxsize 100 class LinearList{ public: LinearList() { last = -1; } //空表时last为-1 int data[Maxsize]; //申请表的空间 int last; //末端元素的下标 bool Isempty(Line...
阅读全文
摘要:多项式的和,例如多项式f1(x)=12x^19+13x^8+4x^5-x^3+1,f(x)=21x^21+12x^19+10x^8+4X^6-X^2+3f1(x)可以表示为(12,19) (13,8) (4,5) (-1,3) (1,0)f2(x)可以表示为(21,21) (12,19)(10,8)...
阅读全文
摘要:默认下都是十进制 int i, j, k, l; cin>>oct>>i; //输入为八进制数 cin>>hex>>j; //输入为十六进制数 cin>>k; //输入仍为十六进制数 cin>>dec>>l; //输入为十进制数 cout<<”hex:”<<”i=”<<hex<<i<<endl; c...
阅读全文
摘要:这个题目明确说了不涉及大数,假设第i个为b[i]:b[0]=s1;b[1]=s2;b[3]=s1+s2;b[4]=s1+2*s2;b[5]=2*s1+3*s2;b[6]=3*s1+5*s2;b[7]=5*s1+8*s2;………………于是s1和s2的系数从某一项开始分别成斐波那契数列,于是只要算出b[...
阅读全文
摘要:这个题目很水,但是卡了格式和m=0的情况,wa了好多次,题目只给出N=1,感觉没说清楚#includeusing namespace std;int main(){ int m, n,a,b,count,times=0,T; cin >> T; while (T--) { times = 0; ...
阅读全文
摘要:#includeusing namespace std;int Maxsum(int*a, int n);int main(){ int T,n,i,j,count=0,thissum,maxsum,redex1,redex0,redex2; cin >> T; while (T--) { cou...
阅读全文
摘要://算法复杂度T=O(n),#includeusing namespace std;int Maxsum(int*a, int n);int main(){ int n, i; int a[100]; while (cin >> n) { for (i = 0; i > a[i]; coutma...
阅读全文
摘要://最大子序列和算法1,算法复杂度T=O(n^2)#includeusing namespace std;int find(int*a,int N);clock_t start, stop;int main(){ int a[25]={1,4,-9,5,3,6,7,1,2,4,-8,-1,4,7,-...
阅读全文
摘要:使用万进制来做相对来说速度要快些#includeusing namespace std;#include#define mun 10000int main(){ int n, i, j, p, c, place; while (cin >> n) { int a[10000]; a[0] = 1...
阅读全文
摘要:数论中模的运算:a*b%n=(a%n)*(b%n)%c;(a+b)%n=(a%n+b%n)%n;幂的模:A^n%c=r 于是A^(n+1)%c=A*r%c;#includeusing namespace std;int main(){ int T,i; _int64 a, b, c, r; //定...
阅读全文
摘要:本题在于求单价,即为每一天(每200升牛奶)要多少钱,注意超过1000的当做5天,不足200的忽略#include#includeusing namespace std;class milk {public: double p; double average; int vol; int day; s...
阅读全文
摘要:简单的找规律,不妨设N=10*x+a(a=N%10),那么N^N=(10*x+a)^N,用二项式展开定理可以知道N^N%10=a^N%10;由于0using namespace std; int main(){ int n, a, T;cin >> T; int p[4]; while (T--) ...
阅读全文
摘要:用string串来处理这个题很方便#include#includeusing namespace std;string cipher(string &s);//引用为参数,此函数返回一个string类的字符串int main(){string s1, s2, s3,s4;while (1){getl...
阅读全文
摘要:打表找规律,发现是n%4==2就是yes,否则是no#includeusing namespace std;int main(){int n;while (cin >> n){if (n % 4 == 2)cout << "yes" << endl;elsecout << "no" << endl;...
阅读全文
摘要:计算n个数的最小公倍数,可用欧几里得算法计算两个数字的最大公约数,再计算两个数最小公倍数有了2个数最小公倍数算法就简单了,即为:计算第一和第二个数得到最小公倍数lc,再计算lc和第三个数最小公倍数......#include#include#includeusing namespace std;in...
阅读全文
摘要:9的余数定理:一个数各位数字的总和除以9的余数与它本身除以9的余数同等大数问题:防止大数,用字符串来存入数据,再转化为数字#include#includeusing namespace std;int main(){int N,i;string s;while (cin>>s){if (s[0] -...
阅读全文
摘要:分清上升停留下降一步步来就是了#include#includeusing namespace std;int main(){int N,n,i,sumtime;while (cin >> N&&N != 0){sumtime = 0;vectorv;for (i = 0; i > n; i++)v....
阅读全文
摘要:字符串统计问题,统计每个字符串的次数,输出出现次数最多的字符串#include#include#includeusing namespace std;int main(){int N,i,redex;while (cin >> N&&N!=0){string str[1000];int number...
阅读全文
摘要:#include#include#includeusing namespace std;typedef vector vt;int main(){int i;vt v1(10); //定义向量10个元素,注意每个元素初始化为了0for (i = 0; i ::iterator it = v2.beg...
阅读全文
摘要://clock()函数为c中,捕捉从程序开始运行到clock运行的时间//时间单位为clock tick,即为时钟打点#include#include#include//包含头文件(C中的写法)using namespace std;clock_t start, stop; //clock_t是cl...
阅读全文