結果

問題 No.339 何人が回答したのか
ユーザー ldsybldsyb
提出日時 2016-03-04 12:20:00
言語 C++11
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 378 bytes
コンパイル時間 419 ms
コンパイル使用メモリ 54,676 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-09-24 14:02:30
合計ジャッジ時間 1,969 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 61
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:20:18: warning: ‘gcdkeep’ may be used uninitialized in this function [-Wmaybe-uninitialized]
   20 |    cout << 100 / gcdkeep << endl;
      |                  ^~~~~~~

ソースコード

diff #

#include <iostream>
using namespace std;

int gcd(int x,int y){
   if((x == 0) || (y == 0)) return 0;
   while(x != y){
      if(x > y) x -= y;
      else y -= x;
   }
   return x;
}

int main(){
   int gcdkeep,n;
   cin >> n;
   for(int a,i = 0;i < n && cin >> a;i++){
      if(i == 0) gcdkeep = a;
      else gcdkeep = gcd(gcdkeep,a);
   }
   cout << 100 / gcdkeep << endl;
}
0