Submission #1304967


Source Code Expand

#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<stdlib.h>
#include<cassert>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=500000004;
const double EPS=1e-10;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
long long fib[100];
vector<pair<long long,long long > > v[100];
void dfs(int a,long long b,long long c,int d){
	if(b&&c/b==1){
		v[a].push_back(make_pair(b,c));
		v[a].push_back(make_pair(c,b));
	}
	if(d==0){
		long long tb=c;
		long long tc=b+c*2;
		if(tb<=fib[a+3]&&tc<=fib[a+3])dfs(a+1,tb,tc,1);
	}
	long long tb=c;
	long long tc=b+c;
	if(tb<=fib[a+3]&&tc<=fib[a+3])dfs(a+1,tb,tc,d);
}
int main(){
	int a;scanf("%d",&a);
	fib[1]=1;
	fib[2]=2;
	for(int i=3;i<100;i++){
		fib[i]=min(inf,fib[i-2]+fib[i-1]);
	}
	dfs(0,1,1,0);
	for(int i=1;i<=4;i++){
//		for(int j=0;j<v[i].size();j++)printf("%d: %lld %lld\n",i,v[i][j].first,v[i][j].second);
	}
	while(a--){
		long long x,y;scanf("%lld%lld",&x,&y);
		if(x>y)swap(x,y);
		int K=1;
		for(int i=98;i>=1;i--){
			if(fib[i]<=x&&fib[i+1]<=y){
				K=i;
				break;
			}
		}
		printf("%d ",K);
		if(K==1){
			printf("%lld\n",(x%mod)*(y%mod)%mod);
			continue;
		}else{
			long long ret=0;
			for(int i=0;i<v[K].size();i++){
				if(v[K][i].first>x||v[K][i].second>y)continue;
				ret=(ret+(y-v[K][i].second)/v[K][i].first+1)%mod;
			}
			printf("%lld\n",ret);
		}
	}
}

Submission Info

Submission Time
Task F - Kenus the Ancient Greek
User tozangezan
Language C++14 (GCC 5.4.1)
Score 1700
Code Size 1627 Byte
Status AC
Exec Time 358 ms
Memory 4224 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:38:22: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  int a;scanf("%d",&a);
                      ^
./Main.cpp:49:40: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   long long x,y;scanf("%lld%lld",&x,&y);
                                        ^

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 226 ms 3328 KB
02.txt AC 226 ms 3408 KB
03.txt AC 225 ms 3328 KB
04.txt AC 225 ms 3408 KB
05.txt AC 225 ms 3408 KB
06.txt AC 225 ms 3408 KB
07.txt AC 226 ms 3328 KB
08.txt AC 225 ms 3456 KB
09.txt AC 225 ms 3408 KB
10.txt AC 226 ms 3408 KB
11.txt AC 275 ms 2048 KB
12.txt AC 275 ms 2048 KB
13.txt AC 166 ms 2048 KB
14.txt AC 167 ms 2048 KB
15.txt AC 191 ms 4224 KB
16.txt AC 191 ms 4224 KB
17.txt AC 162 ms 3840 KB
18.txt AC 162 ms 3968 KB
19.txt AC 358 ms 3712 KB
20.txt AC 357 ms 3712 KB
21.txt AC 1 ms 384 KB
22.txt AC 1 ms 384 KB
23.txt AC 1 ms 384 KB
24.txt AC 1 ms 384 KB
s1.txt AC 1 ms 384 KB
s2.txt AC 1 ms 384 KB