結果
| 問題 |
No.118 門松列(2)
|
| ユーザー |
RCCW
|
| 提出日時 | 2017-03-04 19:40:25 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 10 ms / 5,000 ms |
| コード長 | 886 bytes |
| コンパイル時間 | 1,308 ms |
| コンパイル使用メモリ | 157,440 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-06-23 02:03:45 |
| 合計ジャッジ時間 | 2,289 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 26 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:25:18: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘long long int’ [-Wformat=]
25 | printf("%d",s%=1000000007);
| ~^ ~~~~~~~~~~~~~
| | |
| int long long int
| %lld
main.cpp:10:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
10 | scanf("%d",&n);
| ~~~~~^~~~~~~~~
main.cpp:12:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
12 | scanf("%d",&i);
| ~~~~~^~~~~~~~~
ソースコード
#include "bits/stdc++.h"
using namespace std;
int main(){
int n,i,j,k;
//多めにaの変数を用意しておく分には問題ない。
//最大でも100
//nは数
long long s=0,a[101]={};
scanf("%d",&n);
while(n--){
scanf("%d",&i);
//これで重複カウンターを作れる。
a[i]++;
}//これで組み合わせ総数が足し算で出せる。
//重複しているのは2倍になる。組み合わせの性質で。
//高々最高でも101までなので高さが、それを総当たりで3重ループで求めれる。
//ループが何十だとどれくらいまで求められるかは
//3重だと1000が限度か,1000*1000*1000で
//2重だと10000*10000が限度
//4重だと100*100*100*100か
//5重だと10,10,10,10,10か。
for(k=0;k<101;k++)for(j=k+1;j<101;j++)for(i=j+1;i<101;i++)s+=a[i]*a[j]*a[k];
printf("%d",s%=1000000007);
return 0;
}
RCCW