結果

問題 No.176 2種類の切手
ユーザー 184
提出日時 2015-04-25 20:55:33
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 404 bytes
コンパイル時間 429 ms
コンパイル使用メモリ 41,012 KB
実行使用メモリ 13,640 KB
最終ジャッジ日時 2024-10-08 03:19:37
合計ジャッジ時間 2,678 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample -- * 3
other AC * 2 WA * 1 TLE * 1 -- * 25
権限があれば一括ダウンロードができます
コンパイルメッセージ
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++,c+=n){
		if(c%a==0||c%b==0){ans=c;break;}
	}
	  
	printf("%d\n",ans); 
	return 0;
}
0