結果
問題 | No.415 ぴょん |
ユーザー |
![]() |
提出日時 | 2016-11-17 13:54:29 |
言語 | C90 (gcc 12.3.0) |
結果 |
CE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 978 bytes |
コンパイル時間 | 1,337 ms |
コンパイル使用メモリ | 25,728 KB |
最終ジャッジ日時 | 2025-01-08 15:03:05 |
合計ジャッジ時間 | 2,402 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
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) | ~~~~~~~~~~~~~~~^ main.c: In function 'main': main.c:53:9: error: C++ style comments are not allowed in ISO C90 53 | //lcm(8, 6); | ^ main.c:53:9: note: (this will be reported only once per input file)
ソースコード
#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; }