zoj 2358 Sum of Factorials

//剛開始就搞錯了,以為是要連續數的階乘和,原來只是階乘相加和相等就可以了!#include "iostream"using namespace std;int main(){int i, n;double ans[11];ans[0] = 1;for (i = 1; i < 11; i++)ans[i] = ans[i-1] * i;while (cin >> n && n >= 0){if (n == 0){cout << "NO"

zoj 1858 Soundex

#include "iostream"#include "string"#include "map"using namespace std;int main(){map<char, int> m;string str, ans;int length, i;m['B'] = 1, m['F'] = 1,m['P'] = 1,m['V'] = 1,m['C'] = 2,m['G'] = 2,m['J'] = 2,m['K'] = 2,m['Q'] = 2,m['S'] = 2,

zoj 1951 Goldbach’s Conjecture

//就開始做這題的時候,竟然逾時了,然後改為查表,亦逾時,只好上網參考了別人的做法!#include "iostream"#include "cmath"using namespace std;int primer(int n){int i, k;k = sqrt(double(n));if (n == 1) return 0;for (i = 2; i <= k; i++){if (n % i == 0)return 0;}return 1;}int main(){int num, i;

zoj 2207 Team Rankings

//由字串“ABCDE”的所有排序(可以通過stl中的next_permutation直接得出)與input中//的字串進行比較,找出差距值最小的字串!#include "iostream"#include "map"#include "algorithm"#include "string"#include "limits.h"using namespace std;string input[110];map<char, int> m;int solve(string temp)//

zoj 1006 Do the Untwist

#include "iostream"#include "map"#include "string"#include "memory.h"using namespace std;int main(){int num, i, len;string str, ans;int ciphercode[80], plaincode[80];memset(ciphercode, 0, sizeof(ciphercode));memset(plaincode, 0,

zoj 1874 Primary Arithmetic

#include "stdio.h"#include "iostream"#include "string.h"using namespace std;int main(){char input1[20], input2[20];//對輸入的字元的儲存int num1[20], num2[20];//由字元轉換為數位儲存int len1, len2, i, len, carry, temp, c;while (scanf("%s%s", input1, input2)){carry = c =

zoj 1088 System Overload

#include "iostream"#include "stdio.h"#include "memory.h"using namespace std;int citys[160];int temp[160];bool solve(int n, int m){int r = 1;int i, j;citys[1] = 0;for (i = 2, j = 1; r <= n - 2; i = i % n + 1, j = j % m + 1){while (citys[i] == 0)i =

zoj 2975 Kinds of Fuwas

#include "iostream"#include "stdio.h"#include "string"using namespace std;char num[260][260];char fuwa[] = "BJHYN";int main(){int TestCase, i, j, k, n, count, total, M, N;cin >> TestCase;while (TestCase--){total = 0;cin >> M >>

zoj 1338 Up and Down Sequences

#include "iostream"#include "stdio.h"#include "iomanip"using namespace std;int main(){int num[30], len, i, uptimes, downtimes, midtimes, sum1, sum2;bool up, down;while (cin >> num[0] && num[0]){len = 1;while (cin >> num[len] &

zoj 1337 Pi

#include "iostream"#include "memory.h"#include "math.h"#include "stdio.h"using namespace std;int input[60];int main(){ memset(input, 0, sizeof(input)); int num, i, j, count, sumcount, g, x, y; double pi, ans; while (cin >> num &

zoj 1884 WERTYU

//這題雖然是一道很容易的題目,但是如果不小心的話,會在輸入的時候出錯,輸出時候出錯,還有//在用char和string的區別上出錯!#include "iostream"#include "stdio.h"using namespace std;int main(){char str[50] = "`1234567890-=QWERTYUIOP[]\\ASDFGHJKL;'ZXCVBNM,./";char ch;int i;while ((ch = getchar()) !=

zoj 1259 Rails

//這題對輸入輸出格式有比較嚴格的要求,運用到二重迴圈來很好地解決了問題!#include "iostream"#include "stack"#include "memory.h"using namespace std;int train[1010];int main(){stack<int> s;int num, i, A, B, tag;while (cin >> num && num)//對第一個輸入是否為0的判斷!{memset(train, 0

zoj 2172 Symmetric Order

#include "iostream"#include "string"#include "vector"using namespace std;int main(){int num, i, count = 0;string temp1, temp2;vector<string> v;vector<string> v1;vector<string> v2;vector<string>::iterator it;while (cin >>

zoj 1831 Substitution Cypher

//一直都系輸入這裡出錯了,以為plaintext和substitution就是固定不變的,其實不是,要求你根據給出的//來完成字串的轉換的,我WA了很多次,參考了網上的做法才知道自己是在這方面搞錯了!#include "iostream"#include "string"#include "map"using namespace std;int main(){map<char, char> m;int i, length;string input, a,

zoj 2208 To and Fro

#include "iostream"#include "string"#include "algorithm"using namespace std;string str[25];int main(){int num, i, j, len;string input, ans;while (cin >> num && num){cin >> input;len = input.length();ans.clear();for (i = 0; i <

zoj 1365 Mileage Bank

//這一題簡單題WA了兩次,原因就是在於使用了while(1)這個迴圈輸入條件而沒有及時的退出迴圈,//所以逾時了!要特別注意這一些細微之處!#include "iostream"#include "string"using namespace std;int main(){string str1, str2;int mileage, sum = 0;char classcode;while (cin >> str1){if (str1 == "0"){cout <<

zoj 2321 Filling Out the Team

//沒有仔細的閱讀題目,以致在比較的時候漏掉了等於的情況!#include "iostream"#include "string"#include "vector"using namespace std;struct Info{string pos;double speed;int weight;int strength;};int main(){int weight, strength, i, size;double speed;vector<Info>

zoj 1241 Geometry Made Simple

//由於粗心,連輸出的英文都寫錯,WA了很多次,找到我頭暈了 #include "stdio.h" #include "cmath"int main(){float a,b,c;float ans; int count=0; while(scanf("%f%f%f",&a,&b,&c)&&a!=0&&b!=0&&c!=0){ count++;printf("Triangle #%d\n",count);if (a==-1)

zoj 2421 Recaman’s Sequence

//按題目要求求出其數列!用查表的方法很容易就可以實現!#include "iostream"#include "memory.h"using namespace std;int num[500010];int flag[10000100];//由於數組開小了,所以之前都運行不了!int main(){int k, i;memset(num, 0, sizeof(num));memset(flag, 0, sizeof(flag));num[0] = 0;for (i = 1; i < 5

zoj 1394 Polar Explorer

//WA了很多次,百度了一下,才知道原來是小數與整數之間的錯誤,還不夠細心!#include "iostream"#include "string"using namespace std;const int pi = 3.14159;int main(){string tag1, tag2;double X, Y, Z, distance, abledistance, remain;while (cin >> tag1){if (tag1 == "ENDOFINPUT")

總頁數: 61357 1 .... 19896 19897 19898 19899 19900 .... 61357 Go to: 前往

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.