Submission #1314147
Source Code Expand
#include<iostream> #include<cstdio> #include<algorithm> #include<set> #include<map> #include<queue> #include<cassert> #define PB push_back #define MP make_pair #define sz(v) (in((v).size())) #define forn(i,n) for(in i=0;i<(n);++i) #define forv(i,v) forn(i,sz(v)) #define fors(i,s) for(auto i=(s).begin();i!=(s).end();++i) #define all(v) (v).begin(),(v).end() using namespace std; typedef long long in; typedef vector<in> VI; typedef vector<VI> VVI; in ma,mb; in sc; in sm; in ts,tx,ty; const in mdl=1000000007; VI amax,amay,ambx,amby; void sup(in x, in y, in s){ if(amax[s]*x+amay[s]*y>ma) return; if(ambx[s]*x+amby[s]*y>mb) return; if(s==sc){ sm+=(ma-x)/y+1; if(x<=mb){ ++sm; } sm%=mdl; return; } sup(x+y,y,s); sup(x+y,x,s+1); } void slv(){ if(mb>ma) swap(mb,ma); if(mb==1){ cout<<1<<" "<<ma%mdl<<"\n"; return; } if(mb==2 && ma==2){ cout<<1<<" "<<4<<"\n"; return; } in x=2; in y=1; sc=2; while(x+y<=ma && x<=mb){ y+=x; swap(x,y); ++sc; } amax[sc]=1; amay[sc]=0; ambx[sc]=0; amby[sc]=1; for(in i=sc-1;i>=2;--i){ amax[i]=amax[i+1]+amay[i+1]; amay[i]=amax[i+1]; ambx[i]=ambx[i+1]+amby[i+1]; amby[i]=ambx[i+1]; } cout<<sc-1<<" "; sm=0; sup(2,1,2); cout<<sm<<"\n"; } int main(){ ios::sync_with_stdio(0); cin.tie(0); amax=amay=ambx=amby=VI(200); in q; cin>>q; forn(z,q){ cin>>ma>>mb; slv(); } return 0; }
Submission Info
Submission Time | |
---|---|
Task | F - Kenus the Ancient Greek |
User | w4yneb0t |
Language | C++14 (GCC 5.4.1) |
Score | 1700 |
Code Size | 1544 Byte |
Status | AC |
Exec Time | 3451 ms |
Memory | 4096 KB |
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 | 986 ms | 3200 KB |
02.txt | AC | 984 ms | 3200 KB |
03.txt | AC | 981 ms | 3200 KB |
04.txt | AC | 983 ms | 3200 KB |
05.txt | AC | 986 ms | 3200 KB |
06.txt | AC | 983 ms | 3200 KB |
07.txt | AC | 980 ms | 3200 KB |
08.txt | AC | 1008 ms | 3200 KB |
09.txt | AC | 986 ms | 3200 KB |
10.txt | AC | 990 ms | 3200 KB |
11.txt | AC | 1912 ms | 1920 KB |
12.txt | AC | 1827 ms | 1920 KB |
13.txt | AC | 242 ms | 1792 KB |
14.txt | AC | 242 ms | 1792 KB |
15.txt | AC | 295 ms | 4096 KB |
16.txt | AC | 302 ms | 4096 KB |
17.txt | AC | 116 ms | 3712 KB |
18.txt | AC | 116 ms | 3712 KB |
19.txt | AC | 3451 ms | 3456 KB |
20.txt | AC | 3368 ms | 3456 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 |