Submission #1306211
Source Code Expand
#include <bits/stdc++.h> using namespace std; int TwoIntegers( const int K, const int S ) { if( K < 0 || S < 0 ) return 0; if( K >= S ) return S + 1; if( 2 * K >= S ) return 2 * K - S + 1; else return 0; } int ThreeIntegers( const int K, const int S ) { int i; int iSum; int iMin; int iMax; if( K < 0 || S < 0 ) return 0; if( K > S ) iMax = S; else iMax = K; if( 2 * K < S ) iMin = S - 2 * K; else iMin = 0; iSum = 0; for( i = iMin; i <= iMax; i++ ) iSum += TwoIntegers( K, S - i ); return iSum; } int main( int argc, char *argv[] ) { int K; int S; ios::sync_with_stdio( false ); cin.tie( 0 ); cin >> K; cin >> S; cout << ThreeIntegers( K, S ) << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | B - Sum of Three Integers |
User | New |
Language | C++14 (GCC 5.4.1) |
Score | 200 |
Code Size | 772 Byte |
Status | AC |
Exec Time | 1 ms |
Memory | 256 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 200 / 200 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | sample_01.txt, sample_02.txt |
All | sample_01.txt, sample_02.txt, subtask_1_01.txt, subtask_1_02.txt, subtask_1_03.txt, subtask_1_04.txt, subtask_1_05.txt, subtask_1_06.txt, subtask_1_07.txt, subtask_1_08.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
sample_01.txt | AC | 1 ms | 256 KB |
sample_02.txt | AC | 1 ms | 256 KB |
subtask_1_01.txt | AC | 1 ms | 256 KB |
subtask_1_02.txt | AC | 1 ms | 256 KB |
subtask_1_03.txt | AC | 1 ms | 256 KB |
subtask_1_04.txt | AC | 1 ms | 256 KB |
subtask_1_05.txt | AC | 1 ms | 256 KB |
subtask_1_06.txt | AC | 1 ms | 256 KB |
subtask_1_07.txt | AC | 1 ms | 256 KB |
subtask_1_08.txt | AC | 1 ms | 256 KB |