- 博客(103)
- 收藏
- 关注
原创 抄了一天的CArray的代码
<br />对iterator,reverse_iterator,std::copy还有类里面的static函数有了些了解,果然看比不上写<br /> <br /> <br />template<typename T, size_t count>class CArray{ public: typedef T value_type; typedef T* iterator; typedef const T* const_iterator; typedef s
2011-04-28 01:38:00 319
原创 UVA 10591
#include #include using namespace std;int Hash[730];int digitsum(int n){ int sum = 0; while (n) { sum += (n%10) * (n%10); n /= 10; } return sum;}int HappyNumber(int
2010-05-06 17:34:00 330
原创 UVA 10125
#include #include using namespace std;const int MAXN = 1005;int binarysearch(int A[],int low, int high, int x){ int mid; while (low <= high) { mid = low + (high - low) / 2;
2010-05-05 22:24:00 409
原创 UVA 10282
#include #include #include #define HASHSIZE 1001struct nlist{ struct nlist *next; char *name; char *defn;};static struct nlist *HashMap[HASHSIZE];unsigned hash(char *s){
2010-05-05 22:23:00 340
原创 数字之和
//由RoBa程序改变,感谢/*题目描述:给你两个数 a 和 b , 请你计算 a b 之间所有数的数字之和输入:多组测试数据,每个数据仅一行一行有两个数 a,b (0 <= a,b <= 2e9 )以EOF结束输入输出:a b 之间的数的数字之和样例输入:0 310 140 0样例输出:6150其它信息:
2010-05-05 15:19:00 211
原创 算法入门经典链表数组实现
#include #include int A[500000] = {0};int find(int x, int n){ int i; for (i = 1; i <= n; ++i) if (A[i] == x) return i;}void A_low_high(int low,int high){ int temp = A[low]
2010-03-10 14:08:00 455
原创 取出数组中最大最小值
#include #include #include #define N 9void maxmin(int A[], int n, int *min, int *max){ int i; int k = n / 2; int iTemp; for (i = 0; i < k; ++i) if (A[i] <= A[i+k]) {
2010-03-10 14:05:00 747
原创 UVA 495
#include #include using namespace std;char Fib[5001][1100] = {"0","1","1"};void add(char a[],char b[], char c[]){ int len_a = strlen(a),len_b = strlen(b); int len_c = len_a > len_b ?
2010-01-28 15:31:00 416
原创 UVA 713
#include #include using namespace std;void add(char a[],char b[], char c[]){ int len_a = strlen(a),len_b = strlen(b); int len_c = len_a > len_b ? len_a : len_b; ++len_c; memset(c,0
2010-01-28 11:08:00 231
原创 UVA 623
#include using namespace std;int main(){ int n; while (cin >> n) { int a[1000] = {1},len = 0; for (int i = 2; i <= n; ++i) { int carry = 0,iTemp; for (int j = 0; j <= le
2010-01-25 17:04:00 264
原创 UVA 10994
#include using namespace std;long long add(int temp){ long long sum = 0,tmpsum = 0; if (temp <= 0) return 0; long long n = temp; while (n) { tmpsum = (n / 10) *45; sum += t
2010-01-22 18:07:00 606
原创 UVA 10303
#include using namespace std;int Primes[2000];int Len;void GetPrime(){ bool flag[2001] = { false }; for (int i = 2; i < 46; ++i) if (!flag[i]) for (int j = i + i; j < 2001; j
2010-01-21 17:41:00 293
原创 UVA 10375
#include #include using namespace std;int Primes[1250];int Len;void getprime(){ bool flag[10001] = { false }; for (int i = 2; i < 101; ++i) if (!flag[i]) for (int j = i +
2010-01-19 15:20:00 327
原创 UVA 138
#include #include #include using namespace std;//解方程 n(n+1) = 2 * k^2int main(){ int count = 0; int m = 2,odd = 3; int n[10],k[10]; //1.n = m * m(m为奇数) //2.n = 2 * m * m
2010-01-19 10:36:00 457
原创 UVA 11029
#include #include using namespace std;int main(){ int T; unsigned n,k; scanf("%d",&T); while (T--) { scanf("%d %d",&n,&k); long double lead_mul,temp; temp = n; lead
2010-01-18 14:39:00 425
原创 UVA 133
//附上别人的队列解法#include #include using namespace std;int main(){ int N,k,m; while (cin >> N >> k >> m) { bool flag[20] = {false}; int count = 0; if (!N && !k && !m)
2010-01-17 01:12:00 398
原创 UVA 100
#include using namespace std;unsigned CyCle(unsigned m){ unsigned count = 1; while (m != 1) { if (m & 0x01) m = 3 * m + 1; else m /= 2; count++; } return count;}
2010-01-16 23:10:00 292
原创 UVA 10139
#include using namespace std;int Primes[6550];int Len;void getprime(){ bool flag[65537] = { false }; for (int i = 2; i < 65537; ++i) if (!flag[i]) for (int j = i + i; j < 6553
2010-01-15 18:03:00 228
原创 UVA 10105
#include using namespace std;int A[] = {1,1,2,6,24,120,720,5040,40320,362880,3628800,39916800,479001600};int main(){ int n,k; while (scanf("%d %d",&n,&k) != EOF) { int sum = A[n],te
2010-01-15 16:50:00 341
原创 UVA 10127
#include #include using namespace std;int main(){ int n; while (scanf("%d",&n) != EOF) { int A[10002],i; memset(A,-1,sizeof(A)); A[1] = 1; for (i = 2; i < 10002; ++i) {
2010-01-15 16:28:00 320
原创 UVA 10018
#include using namespace std;unsigned Reverse(unsigned n){ unsigned temp = n,m = 0; while (temp) { m = 10 *m + temp % 10; temp /= 10; } return m;}int main(){ int n;
2010-01-15 00:00:00 240
原创 UVA 10035
#include using namespace std;int main(){ int a,b; while (scanf("%d %d",&a,&b)) { if (a == 0 && b== 0) break; int num = 0,carry = 0; while (1) { if (a == 0 && b == 0
2010-01-14 23:25:00 270
原创 UVA 673
//输入输出上太恶心了,算法很简单#include #include #include using namespace std;int main(){ int n; scanf("%d",&n); getchar(); //这里去除换行符 while (n--) { char str[130] = {0}; gets(str); /
2010-01-14 10:45:00 167
原创 UVA 10673
//完全参看http://www.questtosolve.com/search.php //不知道为什么我的代码过不了#include #include using namespace std;int main(){ int t; scanf("%d",&t); while (t--) { int x,k; scanf("%d %d",&x
2010-01-14 00:35:00 231
原创 UVA(10791)
#include #include using namespace std;int Primes[6550];int Len;void getprime(){ bool flag[65537] = { false}; for (int i = 2; i < 65537;++i) if (!flag[i]) for (int j = i
2010-01-13 22:46:00 319
原创 UVA 10025
//忘记了k = 0时,输出是3(边界条件,感谢http://blog.chinaunix.net/u/7261/article_109529_3.html)#include #include using namespace std;int main(){ int num, k,n; scanf("%d",&num); while (num--) {
2010-01-13 16:35:00 452
原创 UVA 10061
//郁闷死了,一直不对,参看了http://d.hatena.ne.jp/iakasT/20090728/1248747977//感谢日本人,我对数学函数用的还是不行啊#include #include #include using namespace std;int trailzero(int num,int base){ unsigned max = UIN
2010-01-13 13:08:00 783 1
原创 UVA 537
#include #include using namespace std;int main(){ int N,j; scanf("%d",&N); for (j = 1; j <= N; ++j) { double u,i,p; int num = 0; string str; bool flagu = false,flagi = fa
2010-01-05 13:36:00 440
原创 489 Hangman Judge
#include #include #include using namespace std;int main(){ string str1,str2; int iCnt;// freopen("1.txt","r",stdin); while (scanf("%d",&iCnt),iCnt != -1) { cin >> str1 >> str2
2010-01-05 10:29:00 494
原创 UVA 494
#include #include using namespace std;int main(void){ int c,last = EOF; int Num = 0; while ((c = getchar()) != EOF) { if (c == /n) { printf("%d/n",Num); Num = 0;last =
2010-01-05 01:25:00 410
原创 11121 Base -2
#include using namespace std;int main(){ int N; scanf("%d",&N); for (int Cnt = 1; Cnt <= N; ++ Cnt) { int n; scanf("%d",&n); char buf[50] = {0}; if (n == 0) { printf("Ca
2009-12-31 13:28:00 182
原创 106 Fermat vs. Pythagoras
#include #include using namespace std;int gcd(int a,int b){ int temp; while (b) { temp = a; a = b; b = temp % b; } return a;}int main(){ int N; while(scanf("
2009-12-30 14:39:00 244
原创 10006 Carmichael Numbers
#include #include using namespace std;const int NOTFOUND = -1;int Primes[7000];int Len;void GetPrimes(void){ bool flag[65002] = {false}; int i,j; for (i = 2; i < sqrt(65002.0
2009-12-30 11:18:00 184
原创 10161(UVA)
#include #include using namespace std;int main(){ int N; while (scanf("%d",&N),N) { int m,xpos,ypos; m = int(sqrt((double)N)); if (m % 2 == 0) { xpos = m,ypos = 1;
2009-12-25 15:42:00 249
原创 UVA(10719)
#include using namespace std;const int N = 10001;int a[N],b[N];int main(){ int k,ilen,c; //freopen("1.txt","r",stdin); //freopen("2.txt","w",stdout); while(scanf("%d",&k) != EO
2009-12-25 11:01:00 280
原创 10167(UVA)
#include using namespace std;int CherryX[101];int CherryY[101];int main(){ int N;// freopen("1.txt","r",stdin);// freopen("2.txt","w",stdout); while (scanf("%d",&N),N) { for
2009-12-19 23:24:00 340
原创 UVA 993
#include int factor[4] = {2,3,5,7};//2,3,4,5,6,7,8,9int dim[4] = {0};int main(){ int t,N;// freopen("1.txt","r",stdin); scanf("%d",&t); while (t--) { scanf("%d",&N); if (
2009-12-18 14:09:00 275
原创 UVA 10879
#include using namespace std;int main(){ int n,k; //freopen("1.txt","r",stdin); scanf("%d",&n); int iCnt = 1; while (n--) { scanf("%d",&k); int j = 0; for (int i = 2; i *
2009-12-17 22:57:00 241
原创 UVA 10392
#include int primes[79000];int len;void getprimes(){ bool flag[1000005] = {0}; for (int i = 2; i <= 1002;++i) for (int j = 2*i;j <= 1000001;j += i) if (!flag[i]) flag[j]
2009-12-17 22:50:00 274
原创 350 - Pseudo-Random Numbers
#include using namespace std;int main(){ int z,i,m,l; int iCnt = 0;// freopen("1.txt","r",stdin); while (scanf("%d %d %d %d", &z,&i,&m,&l) != EOF) { if (z == 0 && i == 0 && m
2009-12-17 17:43:00 349
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人