Submission #1319211


Source Code Expand

#include <cstdio>
#include <algorithm>

using namespace std;

const int p=1000000007;

long long f[200],f_[200];
long long m,n;
int h,i,s,t;

inline void dfs(int x,int y,long long u,long long v,long long su,long long sv)
{
	if (x==y-1)
	{
		s=(s+(m-u)/v)%p;
		s=(s+(n-u)/v)%p;
	}
	else
	{
		long long tu,tv,tw;
		for (int k=1;;k++)
		{
			tu=v,tv=k*v+u;
			tu=su+(k-1)*v*f_[y-x-2];
			tv=sv+(k-1)*v*f_[y-x-1];
			if ((tu>n) || (tv>m))
				break;
			dfs(x+1,y,v,k*v+u,tu,tv);
		}
	}
	return;
}

int main()
{
	f[0]=0,f[1]=1,f[2]=2;
	for (i=3;i<=100;i++)
		f[i]=f[i-1]+f[i-2];
	f_[0]=1,f_[1]=1;
	for (i=2;i<=100;i++)
		f_[i]=f_[i-1]+f_[i-2];
	scanf("%d",&t);
	for (h=1;h<=t;h++)
	{
		scanf("%lld%lld",&n,&m);
		if (n>m)
			swap(n,m);
		if ((n==1) && (m==1))
		{
			printf("%d %d\n",1,1);
			continue;
		}
		for (i=0;(f[i]<=n) && (f[i+1]<=m);i++);
		printf("%d ",i-1);
		if (i-1==1)
			printf("%lld\n",(m%p)*(n%p)%p);
		else
		{
			s=0;
			dfs(0,i-1,1,1,f[i-1],f[i]);
			printf("%d\n",s);
		}
	}
	return 0;
}

Submission Info

Submission Time
Task F - Kenus the Ancient Greek
User zhan8855
Language C++14 (GCC 5.4.1)
Score 1700
Code Size 1069 Byte
Status AC
Exec Time 2529 ms
Memory 3968 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:43:16: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&t);
                ^
./Main.cpp:46:26: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld%lld",&n,&m);
                          ^

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 788 ms 3072 KB
02.txt AC 787 ms 3072 KB
03.txt AC 784 ms 3072 KB
04.txt AC 789 ms 3072 KB
05.txt AC 787 ms 3072 KB
06.txt AC 787 ms 3072 KB
07.txt AC 786 ms 3072 KB
08.txt AC 784 ms 3200 KB
09.txt AC 785 ms 3072 KB
10.txt AC 789 ms 3072 KB
11.txt AC 1471 ms 1792 KB
12.txt AC 1461 ms 1792 KB
13.txt AC 233 ms 1792 KB
14.txt AC 233 ms 1792 KB
15.txt AC 265 ms 3968 KB
16.txt AC 268 ms 3968 KB
17.txt AC 135 ms 3584 KB
18.txt AC 135 ms 3584 KB
19.txt AC 2527 ms 3456 KB
20.txt AC 2529 ms 3456 KB
21.txt AC 1 ms 128 KB
22.txt AC 1 ms 128 KB
23.txt AC 1 ms 128 KB
24.txt AC 1 ms 128 KB
s1.txt AC 1 ms 128 KB
s2.txt AC 1 ms 128 KB