Submission #10218878
Source Code Expand
#include <bits/stdc++.h> #include <algorithm> #define _GLIBCXX_DEBUG #define rep(i,n) for(int i=0;i<(n);++i) #define all(x) (x).begin(), (x).end() #define PB(x) push_back(x) #define MP(x,y) make_pair(x,y) using namespace std; typedef long long ll; int main() { string s; cin>>s; ll n=s.size()-1; if(n==0) { cout<<(s[0]-48)<<endl; return 0; } //n個についてbit全探索 //t[i]をtrue,falseで判断 ll ans=0; vector<int> t(n); for(int bit=0; bit <(1<<n); ++bit) { for(int i=0;i<n;i++) { if(bit & (1<<i)) t[i]=true; else t[i]=false; } ll tmp=0; rep(i,n) { tmp+=(s[i]-48); if(t[i]==true) { ans+=tmp; tmp=0; if(i==n-1) { ans+=(s[i+1]-48); tmp=0; } } else if(i==n-1) { tmp=tmp*10+(s[i+1]-48); ans+=tmp; tmp=0; } else { tmp=tmp*10; } } } cout<<ans<<endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | C - Many Formulas |
User | hs_tako3 |
Language | C++14 (GCC 5.4.1) |
Score | 300 |
Code Size | 1214 Byte |
Status | AC |
Exec Time | 1 ms |
Memory | 256 KB |
Judge Result
Set Name | Sample | All | ||
---|---|---|---|---|
Score / Max Score | 0 / 0 | 300 / 300 | ||
Status | AC |
|
Set Name | Test Cases |
---|---|
Sample | |
All | 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, sample_01.txt, sample_02.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
01.txt | AC | 1 ms | 256 KB |
02.txt | AC | 1 ms | 256 KB |
03.txt | AC | 1 ms | 256 KB |
04.txt | AC | 1 ms | 256 KB |
05.txt | AC | 1 ms | 256 KB |
06.txt | AC | 1 ms | 256 KB |
07.txt | AC | 1 ms | 256 KB |
08.txt | AC | 1 ms | 256 KB |
09.txt | AC | 1 ms | 256 KB |
10.txt | AC | 1 ms | 256 KB |
sample_01.txt | AC | 1 ms | 256 KB |
sample_02.txt | AC | 1 ms | 256 KB |