結果

問題 No.736 約比
ユーザー weizen
提出日時 2018-09-28 22:07:47
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 630 bytes
コンパイル時間 187 ms
コンパイル使用メモリ 30,464 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-10-12 06:21:26
合計ジャッジ時間 1,565 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 65
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:18:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   18 |         scanf("%d",&N);
      |         ~~~~~^~~~~~~~~
main.cpp:20:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   20 |                 scanf("%lld",a+i);
      |                 ~~~~~^~~~~~~~~~~~
main.cpp:25:23: warning: ‘allgcd’ may be used uninitialized in this function [-Wmaybe-uninitialized]
   25 |                 printf("%lld:",a[i]/allgcd);
      |                 ~~~~~~^~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #

#include <stdio.h>
#include <math.h>

typedef long long ll;
ll gcd(ll a, ll b){
        if(b > a){
                ll swp = b;
                b = a;
                a = swp;
        }
        if(b == 0) return a;
        return gcd(b, a%b);
}
ll a[100];
int main(){
        int N;
        ll allgcd;
        scanf("%d",&N);
        for(int i = 0; i < N; i++){
                scanf("%lld",a+i);
                if(i == 0) allgcd = a[i];
                else allgcd = gcd(allgcd,a[i]);
        }
        for(int i = 0; i < N-1; i++){
                printf("%lld:",a[i]/allgcd);
        }
        printf("%lld\n",a[N-1]/allgcd);
}
0