結果
| 問題 |
No.1185 完全な3の倍数
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-08-22 17:20:24 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 662 bytes |
| コンパイル時間 | 1,569 ms |
| コンパイル使用メモリ | 168,352 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-10-15 11:14:12 |
| 合計ジャッジ時間 | 2,568 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 WA * 1 |
| other | AC * 27 WA * 12 |
コンパイルメッセージ
main.cpp: In function 'int p(std::string, int, int)':
main.cpp:11:1: warning: control reaches end of non-void function [-Wreturn-type]
11 | }
| ^
ソースコード
#include <bits/stdc++.h>
using namespace std;
int p(string S,int i,int count){
if(S.size()==i)return 0;
if(S.at(i)=='3'){count/=4;return p(S,i+1,count);}
if(S.at(i)=='6'){count/=4;return p(S,i+1,count)+count/3;}
if(S.at(i)=='9'){count/=4;return p(S,i+1,count)+count/3*2;}
if(S.at(i)<'3')return 0;
if(S.at(i)<'6')return count/3;
if(S.at(i)<'9')return count/3*2;
}
int main(){
int N;cin>>N;
if(N<100){
cout<<(N-9)/3<<endl;
return 0;
}
int ans=30;
string S=to_string(N);
int count=48;
for(int i=3;i<S.size();i++){
ans+=count;
count*=4;
}
cout<<p(S,0,count)+ans<<endl;
}