結果

問題 No.339 何人が回答したのか
ユーザー Ysmr_RyYsmr_Ry
提出日時 2016-03-03 11:24:41
言語 C++11
(gcc 13.3.0)
結果
AC  
実行時間 1 ms / 1,000 ms
コード長 435 bytes
コンパイル時間 329 ms
コンパイル使用メモリ 22,912 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-09-24 13:42:32
合計ジャッジ時間 1,586 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 61
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:15:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   15 |         scanf( "%d", &N );
      |         ~~~~~^~~~~~~~~~~~
main.cpp:17:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   17 |                 scanf( "%d", A+i );
      |                 ~~~~~^~~~~~~~~~~~~

ソースコード

diff #

// yukicoder 339 (http://yukicoder.me/problems/776)
#include<cstdio>
#define rep(i,a) for(int i=0;i<(a);++i)

const int MAX_N = 100;

int N;
int A[MAX_N];

int gcd( int a, int b )
{ return b ? gcd( b, a%b ) : a; }

int main()
{
	scanf( "%d", &N );
	rep( i, N )
		scanf( "%d", A+i );

	int g = gcd( A[0], A[1] );
	rep( i, N-2 )
		g = gcd( g, A[i+2] );
	
	int ans = 0;
	rep( i, N )
		ans += A[i]/g;

	printf( "%d\n", ans );

	return 0;
}
0