Submission #1773159
Source Code Expand
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
int q;
const ll MOD=1e9+7;
#define S 91
ll fib[S];
typedef pair<ll,ll> pll;
#define pb push_back
#define fi first
#define se second
vector<pll> ex[S];
void sol()
{
ll a,b;
scanf("%lld%lld",&a,&b);
if(a>b) swap(a,b);
int ans=1;
for(int i=2;i<S;i++)
{
if(fib[i]<=a&&fib[i+1]<=b) ans=i;
else break;
}
printf("%d ",ans);
ll tot=0;
if(ans==1)
tot=(a%MOD)*(b%MOD)%MOD; //small enough
else
{
for(unsigned _=0;_<ex[ans-1].size();++_)
{
ll x=ex[ans-1][_].fi,y=ex[ans-1][_].se;
//(y,x+ky)
if(y<=a) tot+=(b-x)/y, tot%=MOD;
if(y<=b) tot+=(a-x)/y, tot%=MOD;
}
}
tot=(tot%MOD+MOD)%MOD;
printf("%d\n",int(tot));
}
int calc(ll x,ll y)
{
if(x<y) swap(x,y);
if(x&&y) return calc(y,x%y)+1;
return 0;
}
void gen(int x)
{
vector<pll>&s=ex[x-1],&t=ex[x];
for(unsigned _=0;_<s.size();++_)
{
pll g=s[_];
if(g.fi>g.se) throw "!!!";
ll tmp=g.se; swap(g.fi,g.se);
for(g.se+=tmp;g.se<=fib[x+2];g.se+=tmp)
{
if(calc(g.fi,g.se)!=x) continue;
t.pb(g);
}
}
sort(t.begin(),t.end());
t.erase(unique(t.begin(),t.end()),t.end());
}
int main()
{
fib[0]=1; fib[1]=1;
for(int i=2;i<S;i++) fib[i]=fib[i-1]+fib[i-2];
ex[1].pb(pll(1,2)); ex[1].pb(pll(1,3));
for(int i=2;i+2<S;i++)
gen(i);
scanf("%d",&q);
while(q--) sol();
}
Submission Info
Submission Time
2017-11-14 22:18:45+0900
Task
F - Kenus the Ancient Greek
User
fjzzq2002
Language
C++14 (GCC 5.4.1)
Score
1700
Code Size
1494 Byte
Status
AC
Exec Time
604 ms
Memory
4096 KB
Compile Error
./Main.cpp: In function ‘void sol()’:
./Main.cpp:21:25: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%lld%lld",&a,&b);
^
./Main.cpp: In function ‘int main()’:
./Main.cpp:76:16: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d",&q);
^
Judge Result
Set Name
Sample
All
Score / Max Score
0 / 0
1700 / 1700
Status
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
317 ms
3328 KB
02.txt
AC
316 ms
3328 KB
03.txt
AC
317 ms
3328 KB
04.txt
AC
317 ms
3328 KB
05.txt
AC
317 ms
3328 KB
06.txt
AC
317 ms
3328 KB
07.txt
AC
317 ms
3328 KB
08.txt
AC
317 ms
3328 KB
09.txt
AC
317 ms
3328 KB
10.txt
AC
317 ms
3328 KB
11.txt
AC
603 ms
1920 KB
12.txt
AC
604 ms
1920 KB
13.txt
AC
215 ms
1920 KB
14.txt
AC
215 ms
1920 KB
15.txt
AC
241 ms
4096 KB
16.txt
AC
241 ms
4096 KB
17.txt
AC
145 ms
3840 KB
18.txt
AC
144 ms
3840 KB
19.txt
AC
522 ms
3584 KB
20.txt
AC
522 ms
3584 KB
21.txt
AC
5 ms
384 KB
22.txt
AC
5 ms
384 KB
23.txt
AC
5 ms
384 KB
24.txt
AC
5 ms
384 KB
s1.txt
AC
5 ms
384 KB
s2.txt
AC
5 ms
384 KB