結果

問題 No.176 2種類の切手
ユーザー 184
提出日時 2015-04-25 23:04:50
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 433 bytes
コンパイル時間 283 ms
コンパイル使用メモリ 41,016 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-10-08 03:20:08
合計ジャッジ時間 1,294 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 3
other WA * 29
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:10:24: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   10 |         int a,b,c;scanf("%d%d%d",&a,&b,&c);
      |                   ~~~~~^~~~~~~~~~~~~~~~~~~

ソースコード

diff #

#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <map>


using namespace std;

int main(){
	int a,b,c;scanf("%d%d%d",&a,&b,&c);
	long long cm=(long long)a*b;if(a>b)swap(a,b);
	int ans=2*1000000000;
	int n=a,m=b;
	int x=0;while(x=m%n){m=n;n=x;};//cm/=n;
	a/=n;b/=n;
	c=(c+n-1)/n*n;
	for(int i=0;i<=a;i++ ){
		if(i*b>c)break;
                ans=min(ans,i*b+(c-(i*b))/a*a+c);
	}
	  
	printf("%d\n",ans); 
	return 0;
}
0