随笔分类 - Water~
摘要:这题应该是个水题,可是我比题还水。。。TT,用map写的,存对应的roma数字时存错啦。。。正好在比赛,我晕,WA了两次,我的排名啊。。。TT#include <iostream>#include <cstdio>#include <cstdlib>#include <map>using namespace std;map<int, string> m;struct roma{ int x; string s;}roma[10010];void init(){ m[1] = "I";m[2] = "II&
阅读全文
摘要:PalindromesA regular palindrome is a string of numbers or letters that is the same forward as backward. For example, the string"ABCDEDCBA"is a palindrome because it is the same when the string is read from left to right as when the string is read from right to left.A mirrored string is a s
阅读全文
摘要:水题,但是要细心#include <stdio.h>#include <stdlib.h>#define N 10007int a[N], b[N];int cmp(const void * a, const void * b){ return *(int *)a - *(int *)b;}int main(){ int n, i; while(scanf("%d", &n) != EOF) { for(i = 0; i < n; i++) scanf("%d", &a[i]); qsort(a, n, si
阅读全文
摘要:今天有点郁闷,想刷两道水题解解闷的,结果找上了这道题,结果。。。。WA了n次,刚开始没考虑到大数,直接写了个整数的递归交上去了,然后WA就下来了!!后来看到discuss里有人说用字符串写,结果整了半天就是WA,没办法,找来别人的代码一看,我晕!以0结束,我直接没判断。。。。悲剧的一天啊~~~ 不说了, 看代码:#include <stdio.h>#include <string.h>int root(int x){ int sum = 0; while(x) { sum += x%10; x /= 10; } if(sum < 10) return sum; e
阅读全文
摘要:一道大水题,居然放了好几个星期才过,无语。。。。#include <stdio.h>#include <string.h>int main(){ char s[100000], tmp[3]; while(gets(s) != NULL) { int i = 0, flag = 0; tmp[2] = 0; while(s[i]) { tmp[0] = s[i]; tmp[1] = s[i+1]; if(!strcmp(tmp, "“") || !strcmp(tmp, "”")) flag = !flag; switch(s[i
阅读全文
摘要:Linear Cellular AutomataA biologist is experimenting with DNA modification of bacterial colonies being grown in a linear array of culture dishes. By changing the DNA, he is able ``program" the bacteria to respond to the population density of the neighboring dishes. Population is measured on a f
阅读全文
摘要:Number SequenceTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 40967Accepted Submission(s): 8785Problem DescriptionA number sequence is defined as follows:f(1) = 1, f(2) = 1, f(n) = (A * f(n - 1) + B * f(n - 2)) mod 7.Given A, B, and n, you are to
阅读全文
摘要:Hangman JudgeIn ``Hangman Judge,'' you are to write a program that judges a series of Hangman games. For each game, the answer to the puzzle is given as well as the guesses. Rules are the same as the classic game of hangman, and are given as follows:The contestant tries to solve to puzzle by
阅读全文
摘要:The Collatz SequenceAn algorithm given by Lothar Collatz produces sequences of integers, and is described as follows:Step 1:Choose an arbitrary positive integerAas the first item in the sequence.Step 2:IfA= 1 then stop.Step 3:IfAis even, then replaceAbyA/ 2 and go to step 2.Step 4:IfAis odd, then re
阅读全文
摘要:Triangle WaveIn this problem you are to generate a triangular wave form according to a specified pair of Amplitude and Frequency.Input and OutputThe input begins with a single positive integer on a line by itself indicating the number of the cases following, each of them as described below. This lin
阅读全文

浙公网安备 33010602011771号