Submission #1945950


Source Code Expand

#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(x,y) (x=min(x,y))
#define chmax(x,y) (x=max(x,y))
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}
#define N 88
ll n = 88, f[N], g[N][N];

int main(){
	mset(f, -1); mset(g, -1);
	f[0] = 0; f[1] = 1;
	rep(i, N-2){
		f[i+2] = f[i]+f[i+1];
		if(f[i+2]>1e18){
			f[i+2] = -1;
			break;
		}
	}
	//rep(i, n) cerr<<f[i]<<endl;
	rep(i, n){
		g[i][0] = 0; g[i][1] = 1;
		rep(j, N-2){
			g[i][j+2] = g[i][j+1]+g[i][j];
			if(j==i) g[i][j+2] += g[i][j+1];
			if(g[i][j+2]>1e18){
				g[i][j+2] = -1;
				break;
			}
		}
	}
	memcpy(g[0], f, sizeof(f));
	ll q;
	cin>>q;
	rep(_, q){
		ll x, y;
		cin>>x>>y;
		if(x>y) swap(x, y);
		int p = 2;
		while(f[p+1]>0&&x>=f[p]&&y>=f[p+1]) p++;
		p--;
		ll res = 0;
		rep(i, p-1){
			if(g[i][p+1]<0) continue;
			if(g[i][p+1]>y||g[i][p]>x) continue;
			if(x>=g[i][p+1]) res++;
			(res+=(y-g[i][p+1])/g[i][p]+1)%=mod;
			//cerr<<i<<" "<<g[i][p]<<" "<<g[i][p+1]<<" "<<res<<endl;
		}
		if(p-1<=1){
			p = 2;
			res = x%mod*(y%mod)%mod;
		}
		cout<<p-1<<" "<<res<<endl;
	}
	return 0;
}

Submission Info

Submission Time
Task F - Kenus the Ancient Greek
User Lepton
Language C++14 (GCC 5.4.1)
Score 1700
Code Size 2089 Byte
Status AC
Exec Time 1109 ms
Memory 4096 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 1700 / 1700
Status
AC × 2
AC × 26
Set Name Test Cases
Sample s1.txt, s2.txt
All 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, 23.txt, 24.txt, s1.txt, s2.txt
Case Name Status Exec Time Memory
01.txt AC 915 ms 3328 KB
02.txt AC 889 ms 3328 KB
03.txt AC 920 ms 3328 KB
04.txt AC 900 ms 3328 KB
05.txt AC 909 ms 3328 KB
06.txt AC 886 ms 3328 KB
07.txt AC 905 ms 3328 KB
08.txt AC 883 ms 3328 KB
09.txt AC 897 ms 3328 KB
10.txt AC 888 ms 3328 KB
11.txt AC 1066 ms 1920 KB
12.txt AC 1068 ms 1920 KB
13.txt AC 749 ms 1920 KB
14.txt AC 741 ms 1920 KB
15.txt AC 859 ms 4096 KB
16.txt AC 864 ms 4096 KB
17.txt AC 775 ms 3840 KB
18.txt AC 771 ms 3840 KB
19.txt AC 1109 ms 3584 KB
20.txt AC 1093 ms 3584 KB
21.txt AC 1 ms 256 KB
22.txt AC 1 ms 256 KB
23.txt AC 1 ms 256 KB
24.txt AC 1 ms 256 KB
s1.txt AC 1 ms 256 KB
s2.txt AC 1 ms 256 KB