Submission #305897
Source Code Expand
#include <bits/stdc++.h> #define all(x) begin(x), end(x) #define rall(x) (x).rbegin(),(x).rend() #define sz(x) ((int)(x).size()) #define REP(i,b,n) for(int i=(int)(b);i<(int)(n);++i) #define rep(i,n) REP(i,0,n) #define repsz(i,v) rep(i,sz(v)) #define eb emplace_back #define mt make_tuple #define aur auto& #define bit(n) (1LL<<(n)) using namespace std; typedef long long ll; //#define int long long static const int INF = 1<<25; static const double EPS = 1e-5; template<class T>bool chmin(T&a,const T&b){if(a<=b)return false;a=b;return true;} template<class T>bool chmax(T&a,const T&b){if(a>=b)return false;a=b;return true;} void solve(ll n){ if(n == 1){ cout << "0 0" << endl; return; } n -= 2; ll d = 1LL<<30; ll t = d*2 - 1; while(d){ ll now = t - d; if((now+2) * (now+1) * 2 > n) t = now; d >>= 1; } n -= t * (t+1) * 2; if(n == 0){ cout << -t-1 << " " << 0 << endl; return ; } ll x = -t-1 + (n+1)/2; ll y = ((t+1) - llabs(x)) * (n%2 == 0 ? +1 : -1); cout << x << " " << y << endl; } bool solve(){ int q; cin >> q; rep(_, q){ ll t; cin >> t; solve(t); } return true; } signed main(){ //cin.tie(0); //ios_base::sync_with_stdio(0); cout.setf(ios::fixed); cout.precision(10); solve(); return 0; } // vim:set foldmethod=marker commentstring=//%s:
Submission Info
Submission Time | |
---|---|
Task | B - n-th Points |
User | MiSawa |
Language | C++11 (GCC 4.8.1) |
Score | 100 |
Code Size | 1481 Byte |
Status | AC |
Exec Time | 512 ms |
Memory | 804 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 | 22 ms | 800 KB |
subtask1_large_01.txt | AC | 455 ms | 800 KB |
subtask1_mini01.txt | AC | 372 ms | 668 KB |
subtask1_random01.txt | AC | 368 ms | 792 KB |
subtask1_random02.txt | AC | 386 ms | 800 KB |
subtask1_random03.txt | AC | 397 ms | 704 KB |
subtask1_random04.txt | AC | 511 ms | 800 KB |
subtask1_random05.txt | AC | 512 ms | 804 KB |
subtask1_random06.txt | AC | 507 ms | 796 KB |
subtask1_random07.txt | AC | 480 ms | 800 KB |
subtask1_random08.txt | AC | 482 ms | 800 KB |