# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1031100 | s_tree | City (JOI17_city) | C++17 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "Device.h"
#include <bits/stdc++.h>
using namespace std;
const int N = 650'010;
vector<long long> nms;
void InitDevice()
{
long double d = 1.05;
long double val = d;
while(val <= N) {
if(!nms.size() or nms.back()!=(int)val)
nms.push_back(val);
val*=d;
}
}
int Answer(long long S, long long T)
{
long long fs = S/(N);
long long ss = fs-1+nms[S%(nms.size())];
long long ft = T/(N);
long long st = ft-1+nms[T%(nms.size())];
if(fs <= ft and st <= ss)return 1;
if(ft <= fs and ss <= st)return 0;
return 2;
}
#include "Device.h"
#include <bits/stdc++.h>
using namespace std;
const int N = 700'010;
vector<long long> nms;
void InitDevice()
{
long double d = 1.05;
long double val = d;
while(val <= N) {
if(!nms.size() or nms.back()!=(int)val)
nms.push_back(val);
val*=d;
}
}
int Answer(long long S, long long T)
{
long long fs = S/(N);
long long ss = fs-1+nms[S%(N)];
long long ft = T/(N);
long long st = ft-1+nms[T%(N)];
if(fs <= ft and st <= ss)return 1;
if(ft <= fs and ss <= st)return 0;
return 2;
}