Submission #305674
Source Code Expand
#define _USE_MATH_DEFINES #define _CRT_SECURE_NO_DEPRECATE #include <cstdio> #include <cstdlib> #include <cstring> #include <cmath> #include <climits> #include <cfloat> #include <ctime> #include <cassert> #include <map> #include <utility> #include <set> #include <iostream> #include <memory> #include <string> #include <vector> #include <algorithm> #include <functional> #include <sstream> #include <complex> #include <stack> #include <queue> #include <numeric> #include <list> #include <iomanip> #include <fstream> #include <iterator> #include <bitset> using namespace std; typedef long long ll; typedef pair<int, int> Pii; typedef pair<ll, ll> Pll; #define FOR(i,n) for(int i = 0; i < (n); i++) #define sz(c) ((int)(c).size()) #define ten(x) ((int)1e##x) template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; } template<class T> T lcm(T a, T b) { return a / gcd(a, b) * b; } int q; ll abs_sum(ll n) { ll l = -1, r = ten(9); while (r - l != 1) { ll md = (l + r) / 2; ll val = md * (md + 1) * 2 + 1; if (n <= val) r = md; else l = md; } return r; } int main(){ cin >> q; FOR(i, q) { ll n; cin >> n; ll abs_xy = abs_sum(n); n -= 1 + abs_xy * (abs_xy - 1) * 2; n--; ll x = (n + 1) / 2 - abs_xy; ll y = abs_xy - abs(x); if (n % 2 == 1) y = -y; cout << x << " " << y << endl; } }
Submission Info
Submission Time | |
---|---|
Task | B - n-th Points |
User | math |
Language | C++11 (GCC 4.8.1) |
Score | 100 |
Code Size | 1397 Byte |
Status | AC |
Exec Time | 485 ms |
Memory | 808 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 100 / 100 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | subtask0_sample_01.txt |
All | subtask0_sample_01.txt, subtask1_large_01.txt, subtask1_mini01.txt, subtask1_random01.txt, subtask1_random02.txt, subtask1_random03.txt, subtask1_random04.txt, subtask1_random05.txt, subtask1_random06.txt, subtask1_random07.txt, subtask1_random08.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
subtask0_sample_01.txt | AC | 23 ms | 804 KB |
subtask1_large_01.txt | AC | 475 ms | 800 KB |
subtask1_mini01.txt | AC | 343 ms | 796 KB |
subtask1_random01.txt | AC | 394 ms | 804 KB |
subtask1_random02.txt | AC | 370 ms | 800 KB |
subtask1_random03.txt | AC | 373 ms | 676 KB |
subtask1_random04.txt | AC | 478 ms | 796 KB |
subtask1_random05.txt | AC | 474 ms | 800 KB |
subtask1_random06.txt | AC | 480 ms | 804 KB |
subtask1_random07.txt | AC | 485 ms | 808 KB |
subtask1_random08.txt | AC | 476 ms | 676 KB |