一.1075
#include <stdio.h>
int gcd(int x, int y){
if(y == 0) return x;
return gcd(y, x % y);
}
int main() {
int x, y;
while(scanf("%d%d", &x, &y) != EOF){
if(x == y && x == 0) break;
if(x < y){
x ^= y;
y ^= x;
x ^= y;
}
printf("%d\n", x * y / gcd(x, y));
}
return 0;
}
二.1138
#include <stdio.h>
int gcd(int x, int y){
if(y == 0) return x;
return gcd(y, x % y);
}
int C(int x){
return (x - 1) * x / 2;
}
int main() {
int n, x, y;
scanf("%d", &n);
while(n--){
scanf("%d%d", &x, &y);
if(x == y) printf("0\n");
else if(y == 0 || x == 2 || y == 1) printf("1\n");
else {
int s = C(x) - C(y), m = C(x);
int z = gcd(m, s);
printf("%d/%d\n", s / z, m / z);
}
}
return 0;
}
三.1162
#include <stdio.h>
int main() {
int n;
while(scanf("%d", &n)){
if(n == -1) break;
int cnt = 0, x;
for(int i = 0; i < 7; i++){
if(n % 2 == 1) cnt++;
n /= 2;
}
if(cnt % 2 == 0 && n == 0) printf("Yes\n");
else if(cnt % 2 && n) printf("Yes\n");
else printf("No\n");
}
return 0;
}
四.1150
#include <stdio.h>
int main() {
int arr[9];
arr[0] = 1;
for(int i = 1; i < 9; i++) arr[i] = arr[i - 1] * (i + 1);
int n, flag = 0, i;
while(scanf("%d", &n)!=EOF){
for(i = 8; i >= 0; i--){
if(n >= arr[i]) break;
}
if(n == 0) printf("0");
while(i != -1){
printf("%d", n / arr[i]);
n %= arr[i];
i--;
}
printf("\n");
}
return 0;
}
五.1170
#include <stdio.h>
char min(char a, char b){
return a < b ? a : b;
}
int main() {
int n;
while(scanf("%d", &n) != EOF && n != 0){
char a[105], b[105], c[105];
int d[5] = {0};
scanf("%s", a);
scanf("%s", b);
scanf("%s", c);
for(int i = 0; i < n; i++){
printf("%c", min(a[i], min(b[i], c[i])));
d[min(a[i], min(b[i], c[i])) - 'A']++;
}
printf("\n");
for(int i = 0; i < 5; i++){
if(i != 0) printf(" ");
printf("%d", d[i]);
}
printf("\n");
}
return 0;
}
六.1171
#include <stdio.h>
int main() {
int n, arr1[40] = {0}, arr2[40] = {0};
arr1[0] = 1, arr2[0] = 1;
for(int i = 1; i < 40; i++){
arr1[i] += arr2[i - 1];
arr2[i] += arr1[i - 1] + arr2[i - 1];
//printf("%d %d\n", arr1[i], arr2[i]);
}
while(scanf("%d", &n) !=EOF && n != 0){
printf("%d\n", arr1[n - 1] + arr2[n - 1]);
}
return 0;
}
七.1172
#include <stdio.h>
int main() {
int n;
while(scanf("%d", &n) != EOF && n != 0){
long long sum = 0;
for(int i = 1; i * i <= n; i++){
if(n % i == 0) sum += i + n / i;
if(i * i == n) sum -= i;
}
printf("%lld\n", sum);
}
return 0;
}