Submission #1753828


Source Code Expand

#include <cstdio>
#include <vector>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
typedef long long ll ;
#define rep(i, a, b) for (int i = a; i <= b; ++ i) 
const ll inf = 1e18 ;
const int mo = 1e9 + 7 ;
using namespace std ;

ll f[105] ;
vector <pair <ll, ll> > P[105] ;

void pre() {
	f[0] = f[1] = 1 ;
	int n = 1 ;
	rep(i, 2, 100) {
		f[i] = f[i - 1] + f[i - 2] ;
		if (f[i] <= inf) n = i ; else break ;
	}
	P[0].push_back(make_pair(1, 1)) ;
	rep(i, 0, n - 3) {
		rep(j, 0, (int) P[i].size() - 1) {
			ll x = P[i][j].first, y = P[i][j].second ;
			for ( ; ; ) {
				x += y ;
				if (x > f[i] + f[i + 3]) break ;
				P[i + 1].push_back(make_pair(y, x)) ;
			}
		}
	}
}

int main() {
	pre() ;
	int m ;
	ll x, y ;
	scanf("%d", &m) ;
	rep(cas, 1, m) {
		scanf("%lld%lld", &x, &y) ;
		if (x > y) swap(x, y) ;
		int ans = 1 ;
		rep(i, 1, 100) if (f[i] <= x && f[i + 1] <= y) ans = i ; else break ;
		printf("%d ", ans) ;
		if (ans == 1) {
			printf("%lld\n", (ll) x * y % mo) ;
			continue ;
		}
		int k = ans ;
		ans = 0 ;
		rep(i, 0, (int) P[k - 1].size() - 1) {
			ll A = P[k - 1][i].first, B = P[k - 1][i].second ;
			if (B <= x) ans += ((y - A) / B) % mo, ans %= mo ;
			if (B <= y) ans += ((x - A) / B) % mo, ans %= mo ;
		}
		printf("%d\n", (ans + mo) % mo) ;
	}
	return 0 ;
}

Submission Info

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

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:40:18: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &m) ;
                  ^
./Main.cpp:42:29: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   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 338 ms 3328 KB
02.txt AC 338 ms 3328 KB
03.txt AC 338 ms 3328 KB
04.txt AC 339 ms 3328 KB
05.txt AC 340 ms 3328 KB
06.txt AC 339 ms 3328 KB
07.txt AC 338 ms 3328 KB
08.txt AC 337 ms 3328 KB
09.txt AC 338 ms 3328 KB
10.txt AC 339 ms 3328 KB
11.txt AC 652 ms 1920 KB
12.txt AC 651 ms 1920 KB
13.txt AC 229 ms 1920 KB
14.txt AC 229 ms 1920 KB
15.txt AC 258 ms 4224 KB
16.txt AC 254 ms 4096 KB
17.txt AC 146 ms 3840 KB
18.txt AC 146 ms 3840 KB
19.txt AC 572 ms 3584 KB
20.txt AC 572 ms 3584 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