#include <iostream> #include <memory.h>using namespace std;int self_number[100000];//剛開始的時候,因為數組開得太小了,貢獻了3次RE,慘!因為它的相加之和會大於10000的! int main(){ int i, tmp, ans; memset(self_number, 0, sizeof(self_number)); for (i = 1; i <= 1000
#include <iostream>#include <cstdio>#include <cmath>using namespace std;int main(){ int tc, c = 0; long long sum, tmp1, tmp2, n , m; cin >> tc; while (tc--){ c++; cin >> n >> m;
//這題類比題搞死人了:首先桌子是分類的,如果你來的人數是1或者2,只可以坐 two-seat tables類型,如果你來的人數是2或者3人,只可以坐// four-seat tables 類型,如果來的人數是5或者6人,只可以坐 six-seat tables類型,就算其他的桌子類型有空出來了,你也不可以坐,你只可以//等你所需要的那種類型;第二個值得注意的地方就是:they have to wait until some suitable table is free and //there
//給出一個偶數,要求在這個偶數的範圍內,有幾對素數和是等於這個偶數的,注意素數對的不重複性! #include <iostream>#include <cmath>using namespace std;bool is_primer(int n){ if (n == 1) return 0; int i, m; m = sqrt(float(n)); for (i = 2; i <= m; i++) if (n %
//貢獻了一次WA,原因是忽略了下面這句話:“Note that classmate number 1 initially has the ball and tosses it to classmate k. //Thus, number 1 has not yet been tossed the ball and so does not switch the direction he is thinking. ”
//簡單的類比題,按部就班地按照題目的意思做就很容易了,給定一定範圍,將這範圍內的地方塗黑或者塗白,最後統計黑色方格的個數! #include <iostream>#include <string>using namespace std;int grid[105][105];int main(){ int i, j, tc, x, y, l, boardx, boardy, ans = 0; string str; for (i = 1; i <=
//注意:要讀懂題意:不是隨便地從兩個字串中找出相同的字元就可以,而是在字串進行逐個逐個比較的過程中找出! #include <iostream>#include <string>#include <algorithm>using namespace std;int gcd(int a, int b){ while (b%a) { int t = a; a = b % a; b = t;