Square Numbers
中文題目:https://zerojudge.tw/ShowProblem?problemid=d186
#include <iostream>
#include <cmath>
using namespace std;
int main() {
int a, b;
while (cin >> a >> b && a + b){
int n1 = sqrt(a);
int n2 = sqrt(b);
if (n1*n1 != a) n1++;
cout << n2 - n1 + 1 << "\n";
}
return 0;
}
B2-Sequence
題目:https://onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem&problem=2004#google_vignette中文題目:https://zerojudge.tw/ShowProblem?problemid=d123
#include <iostream>
using namespace std;
#define maxn 20005
int main() {
int n, Case = 1;
while (cin >> n) {
int b[n], sum[maxn];
for (int i = 0; i < n; i++) {
cin >> b[i];
}
for (int i = 0; i < maxn; i++) {
sum[i] = 0;
}
bool flag = true;
for (int i = 0; i < n; i++) {
for (int j = i; j < n; j++) {
int x = b[i] + b[j];
if (sum[x]) {
flag = false;
break;
} else {
sum[x] = 1;
}
}
if (!flag) break;
}
if (flag) cout << "Case #" << Case++ << ": It is a B2-Sequence.\n\n";
else cout << "Case #" << Case++ << ": It is not a B2-Sequence.\n\n";
}
return 0;
}
Back to High School Physics
中文題目:https://zerojudge.tw/ShowProblem?problemid=d226
#include <iostream>
using namespace std;
int main() {
int v, t;
while (cin >> v >> t){
cout << 2 * v * t << "\n";
}
return 0;
}