Submission #1239813
Source Code Expand
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc=new Scanner(System.in); String s=sc.next(); int n=s.length(); long answer=0; char[] input=s.toCharArray(); for(int mask=0;mask<(1<<n-1);mask++){ StringBuilder sb=new StringBuilder(); long sum=0; for(int i=0;i<n;i++){ sb.append(input[i]); if((mask & (1<<i)) !=0){ sum+=Long.parseLong(sb.toString()); sb.setLength(0); } } if(sb.length()!=0){ sum+=Long.parseLong(sb.toString()); } answer+=sum; } System.out.println(answer); } }
Submission Info
Submission Time | |
---|---|
Task | C - Many Formulas |
User | kwkm0429 |
Language | Java8 (OpenJDK 1.8.0) |
Score | 300 |
Code Size | 636 Byte |
Status | AC |
Exec Time | 102 ms |
Memory | 23892 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 | 99 ms | 23124 KB |
02.txt | AC | 97 ms | 23892 KB |
03.txt | AC | 98 ms | 20692 KB |
04.txt | AC | 94 ms | 21204 KB |
05.txt | AC | 92 ms | 18900 KB |
06.txt | AC | 102 ms | 23124 KB |
07.txt | AC | 98 ms | 21844 KB |
08.txt | AC | 98 ms | 19540 KB |
09.txt | AC | 92 ms | 18900 KB |
10.txt | AC | 92 ms | 18632 KB |
sample_01.txt | AC | 92 ms | 19284 KB |
sample_02.txt | AC | 98 ms | 21972 KB |