赞
踩
#include <stdio.h>
int main()
{
int a = 1, b = 0, t;
scanf("%d", &t);
for (int i = 0; i < t;i++){
int temp_a = b;
int temp_b = a * 3 + 2 * b;
a = temp_a;
b = temp_b;
}
printf("%d %d", a, b);
}
#include <stdio.h>
int main()
{
int a, b, c;
scanf("%d%d%d", &a, &b, &c);
for (int i = 10; i <= 100;i++){
if(i % 3 == a && i % 5 == b && i % 7 == c){
printf("%d", i);
return 0;
}
}
printf("-1");
}
#include <stdio.h> int seven(int n){ if (n % 7 == 0) return 1; else { while(n){ if(n % 10 == 7){ return 1; } n /= 10; } return 0; } } int main() { int n; scanf("%d", &n); for (int i = 7; i <= n;i++){ if(seven(i)){ printf("%d ", i); } } }
#include <stdio.h> #include <math.h> typedef long long ll; // 求x, y,使得ax + by = gcd(a, b) ll exgcd(ll a, ll b, ll *x, ll *y) { if (!b) { *x = 1; *y = 0; return a; //到达递归边界开始向上一层返回 } ll d = exgcd(b, a % b, x, y); ll temp = *x; //推出这一层的x,y *x = *y; *y = temp - (a / b) * *y; return d; } int main() { ll x, y, a, b, l; scanf("%lld%lld%lld%lld%lld", &x, &y, &a, &b, &l); ll m = 0, n = 0, o, s; o = exgcd(abs(a - b),l, &m, &n); // a表示跳的次数,b表示圈数 if ((x - y) % o != 0 || a == b) printf("Impossible\n"); else { s = l / o; m = m * ((x - y) / o); m = (m % s + s) % s; printf("%lld", m); } }
#include <stdio.h> int main() { int a, b, n = 1; double m = 1; scanf("%d%d", &a,&b); double sum = 1; int begin = 1; int end = 1; int flag = 0; while(sum < b){ n++; m += 1.0 / (double)n; sum += 1.0 / (double)m; if(sum > a){ if(flag == 0){ begin = n; flag = 1; } if(sum < b){ end = n; } } } printf("%d %d", begin, end); }
#include <stdio.h> int isPrime(int n) { for (int i = 2; i * i <= n;i++){ if(n % i ==0) return 0; } return 1; } int main() { int n, cnt1 = 1, cnt2 = 0,sum_number; scanf("%d", &n); while(1) { sum_number = 1; for (int i = (cnt1 - 1) * 100 + 1; i <= (cnt1 - 1) * 100 + 99;i += 2) { if(isPrime(i)){ sum_number = 0; break; } } if(sum_number == 1){ cnt2++; } if(cnt2 == n){ printf("%d %d", (cnt1 - 1) * 100 + 0, (cnt1 - 1) * 100 + 99); break; } cnt1++; } }
#include <stdio.h> void recheck(int a,int b,int n) { int num[10]; for (int i = 0; i < 5; i++){ num[i] = a % 10; a = a / 10; } for (int i = 0; i < 5; i++) { num[i + 5] = b % 10; b = b / 10; } for (int k = 0; k < 10; k++) //判断a和b的各位数字是否有重复 { for (int j = 0; j < k;j++){ if(num[k] == num[j]) return; } } printf("%d%d%d%d%d/%d%d%d%d%d=%d\n", num[9], num[8], num[7], num[6], num[5], num[4], num[3], num[2], num[1], num[0], n); return; //若各位数字都不同,则返回1 } int main() { int n, a, b; scanf("%d", &n); for (int i = 1234;i * n <=98765;i++){ recheck(i, n * i, n); } }
#include <stdio.h>
int main()
{
int k;
scanf("%d", &k);
for (int i = k + 1; i <= 2 * k;i++)
{
if((i * k) % (i - k) == 0)
{
printf("1/%d=1/%d+1/%d\n", k, (i * k) / (i - k),i);
}
}
}
#include <stdio.h> int main() { int a, b, c; int num[102]; scanf("%d%d%d", &a, &b, &c); int ans = a / b, carry = 0; num[0] = ans; for (int i = 1; i <= c + 1;i++) { a = a * 10; ans = (a / b) % 10; a = a % b; num[i] = ans; } if(num[c+1] >= 5){ num[c]++; } for (int i = c; i >= 1;i--) { if(num[i] > 9){ num[i] -= 10; num[i - 1] += 1; } } printf("%d.",num[0]); for (int i = 1; i <= c;i++){ printf("%d",num[i]); } }
#include <stdio.h> void recheck(int a, int b, int c) { int num[9]; for (int i = 0; i < 3; i++) { num[i] = a % 10; a = a / 10; } for (int i = 0; i < 3; i++) { num[i + 3] = b % 10; b = b / 10; } for (int i = 0; i < 3; i++) { num[i + 6] = c % 10; c = c / 10; } for (int k = 0; k < 9; k++) { for (int j = 0; j < k; j++) { if (num[k] == num[j] || num[k] == 0) return; } } printf("%d%d%d %d%d%d %d%d%d\n", num[2], num[1], num[0], num[5], num[4], num[3], num[8], num[7], num[6]); return; //若各位数字都不同,则返回1 } int main() { for (int i = 111; i <= 333;i++) { int j = i * 2; int k = i * 3; recheck(i, j, k); } }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。