Submission #38408
Source Code Expand
#include <cstdio> #include <vector> #include <deque> #include <queue> #include <map> #include <algorithm> #include <functional> #include <iostream> #include <string> #include <cmath> using namespace std; void returnTuple(long long n, vector<long long> &tuple){ long long triNum = 1; long long sum = 2; while(1){ if (n <= triNum){ long long diff = triNum - n; tuple[0] = 1 + diff; tuple[1] = sum - tuple[0]; return; } triNum += sum; ++sum; } } long long returnIndex(vector<long long> &tuple){ long long triNum = 0; long long sum = 2; while(1){ if (sum == tuple[0] + tuple[1]){ return triNum + tuple[1]; } triNum += sum-1; ++sum; } } int main(void) { long long i, j; cin >> i >> j; // debug //for(long long i = 100000000-4; i < 100000000; ++i){ // for(long long i = 1; i < 100; ++i){ // vector<long long> tmp(2); // returnTuple(i, tmp); // cout << "i[" << i << "] = " << tmp[0] << ", " << tmp[1] << endl; // // cout << "ret index = " << returnIndex(tmp) << endl; // } vector<long long> t1(2); vector<long long> t2(2); returnTuple(i, t1); returnTuple(j, t2); t1[0] += t2[0]; t1[1] += t2[1]; cout << returnIndex(t1) << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | C - 紅茶(Tea) |
User | minus9d |
Language | C++ (GCC 4.4.7) |
Score | 1500 |
Code Size | 1457 Byte |
Status | AC |
Exec Time | 26 ms |
Memory | 892 KB |
Judge Result
Set Name | All | ||
---|---|---|---|
Score / Max Score | 1500 / 1500 | ||
Status |
|
Set Name | Test Cases |
---|---|
All | 01-1.txt, 01-2.txt, 01-3.txt, 01-4.txt, 01-5.txt, 02-1.txt, 02-2.txt, 02-3.txt, 02-4.txt, 02-5.txt, 03-1.txt, 03-2.txt, 03-3.txt, 03-4.txt, 03-5.txt, 04-1.txt, 04-2.txt, 04-3.txt, 04-4.txt, 04-5.txt, 05-1.txt, 05-2.txt, 05-3.txt, 05-4.txt, 05-5.txt, 06-1.txt, 06-2.txt, 06-3.txt, 06-4.txt, 06-5.txt, 07-1.txt, 07-2.txt, 07-3.txt, 07-4.txt, 07-5.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
01-1.txt | AC | 21 ms | 780 KB |
01-2.txt | AC | 21 ms | 776 KB |
01-3.txt | AC | 24 ms | 848 KB |
01-4.txt | AC | 22 ms | 780 KB |
01-5.txt | AC | 21 ms | 780 KB |
02-1.txt | AC | 21 ms | 784 KB |
02-2.txt | AC | 21 ms | 780 KB |
02-3.txt | AC | 21 ms | 764 KB |
02-4.txt | AC | 22 ms | 892 KB |
02-5.txt | AC | 26 ms | 888 KB |
03-1.txt | AC | 21 ms | 776 KB |
03-2.txt | AC | 21 ms | 780 KB |
03-3.txt | AC | 21 ms | 776 KB |
03-4.txt | AC | 21 ms | 776 KB |
03-5.txt | AC | 19 ms | 768 KB |
04-1.txt | AC | 19 ms | 776 KB |
04-2.txt | AC | 19 ms | 732 KB |
04-3.txt | AC | 22 ms | 776 KB |
04-4.txt | AC | 21 ms | 776 KB |
04-5.txt | AC | 19 ms | 728 KB |
05-1.txt | AC | 21 ms | 764 KB |
05-2.txt | AC | 21 ms | 776 KB |
05-3.txt | AC | 21 ms | 772 KB |
05-4.txt | AC | 21 ms | 776 KB |
05-5.txt | AC | 22 ms | 732 KB |
06-1.txt | AC | 21 ms | 780 KB |
06-2.txt | AC | 21 ms | 776 KB |
06-3.txt | AC | 21 ms | 776 KB |
06-4.txt | AC | 21 ms | 768 KB |
06-5.txt | AC | 22 ms | 776 KB |
07-1.txt | AC | 21 ms | 780 KB |
07-2.txt | AC | 21 ms | 784 KB |
07-3.txt | AC | 21 ms | 764 KB |
07-4.txt | AC | 22 ms | 772 KB |
07-5.txt | AC | 19 ms | 720 KB |