結果
問題 |
No.415 ぴょん
|
ユーザー |
![]() |
提出日時 | 2025-10-05 17:50:34 |
言語 | C90 (gcc 12.3.0) |
結果 |
AC
|
実行時間 | 1 ms / 1,000 ms |
コード長 | 980 bytes |
コンパイル時間 | 338 ms |
コンパイル使用メモリ | 36,324 KB |
実行使用メモリ | 7,716 KB |
最終ジャッジ日時 | 2025-10-05 17:50:36 |
合計ジャッジ時間 | 1,559 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 27 |
コンパイルメッセージ
main.c: In function 'lcm': main.c:16:23: warning: passing argument 1 of 'swap' makes pointer from integer without a cast [-Wint-conversion] 16 | if(m < n)swap(m, n); | ^ | | | long long int main.c:4:26: note: expected 'long long int *' but argument is of type 'long long int' 4 | void swap(long long int *a, long long int *b) | ~~~~~~~~~~~~~~~^ main.c:16:26: warning: passing argument 2 of 'swap' makes pointer from integer without a cast [-Wint-conversion] 16 | if(m < n)swap(m, n); | ^ | | | long long int main.c:4:44: note: expected 'long long int *' but argument is of type 'long long int' 4 | void swap(long long int *a, long long int *b) | ~~~~~~~~~~~~~~~^
ソースコード
#include <stdio.h> #include <string.h> void swap(long long int *a, long long int *b) { long long int temp; temp = *a; *a = *b; *b = temp; } int lcm(long long int m, long long int n) { long long int temp; if(m < n)swap(m, n); while(n != 0){ temp = n; n = m % n; m = temp; } return m; } int main(void) { int i; int pos; int foot[20] = {0}; long long int n, d; int cnt; /* for(n = 1;n < 10;n++){ for(d = 1;d <= n;d++){ printf("n = %lld, d = %lld : ", n, d); memset(foot, (int)0, sizeof(foot)); pos = 1; cnt = 0; while(foot[pos] != 1){ printf("%d ", pos); foot[pos] = 1; cnt++; pos = (pos - 1 + d) % n + 1; } printf(" %d times\n", cnt - 1); } printf("\n"); } */ /*/lcm(8, 6);*/ scanf("%lld%lld", &n, &d); if(n == d)printf("0\n"); else if(d == 1 || n - 1 == d)printf("%lld\n", n - 1); else if(lcm(n, d) == 1)printf("%lld\n", n - 1); else { printf("%lld\n", n / lcm(n, d) - 1); } return 0; }