結果
| 問題 |
No.917 Make One With GCD
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-10-25 22:46:57 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 2,000 ms |
| コード長 | 373 bytes |
| コンパイル時間 | 898 ms |
| コンパイル使用メモリ | 79,032 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-06-24 11:05:32 |
| 合計ジャッジ時間 | 1,850 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 32 |
コンパイルメッセージ
main.cpp:7:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
7 | main()
| ^~~~
ソースコード
#include<iostream>
#include<map>
using namespace std;
map<int,long>M;
int N;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
main()
{
cin>>N;
M[0]=1;
for(int i=0;i<N;i++)
{
int A;cin>>A;
map<int,long>U;
for(map<int,long>::iterator it=M.begin();it!=M.end();it++)
{
U[it->first]+=it->second;
U[gcd(it->first,A)]+=it->second;
}
M=U;
}
cout<<M[1]<<endl;
}