Submission #2701019
Source Code Expand
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define int ll #define REP(i,n) for(int i=0;i<n;++i) #define SORT(name) sort(name.begin(), name.end()) #define ZERO(p) memset(p, 0, sizeof(p)) #define MINUS(p) memset(p, -1, sizeof(p)) #if 1 # define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__) #else # define DBG(fmt, ...) #endif const ll LLINF = (1LL<<60); const int INF = (1LL<<30); const int MOD = 1000000007; #define MAX_N 100010 int N; int digits_sum(int num) { string s = to_string(num); int res = 0; REP(i, s.length()) { int digit = s[i] - '0'; res += digit; } return res; } signed main() { cin >> N; int ans = INF; for(int A = 1; A < N; ++A) { int B = N - A; ans = min(ans, digits_sum(A) + digits_sum(B)); } printf("%lld\n", ans); return 0; }
Submission Info
Submission Time | |
---|---|
Task | A - Digits Sum |
User | VTR |
Language | C++14 (GCC 5.4.1) |
Score | 200 |
Code Size | 896 Byte |
Status | AC |
Exec Time | 31 ms |
Memory | 384 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 200 / 200 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | sample1.txt, sample2.txt |
All | sample1.txt, sample2.txt, in1.txt, in10.txt, in2.txt, in3.txt, in4.txt, in5.txt, in6.txt, in7.txt, in8.txt, in9.txt, sample1.txt, sample2.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
in1.txt | AC | 3 ms | 256 KB |
in10.txt | AC | 4 ms | 256 KB |
in2.txt | AC | 5 ms | 256 KB |
in3.txt | AC | 16 ms | 256 KB |
in4.txt | AC | 26 ms | 384 KB |
in5.txt | AC | 1 ms | 256 KB |
in6.txt | AC | 27 ms | 256 KB |
in7.txt | AC | 1 ms | 256 KB |
in8.txt | AC | 1 ms | 256 KB |
in9.txt | AC | 1 ms | 256 KB |
sample1.txt | AC | 1 ms | 256 KB |
sample2.txt | AC | 31 ms | 256 KB |