Submission #2235357
Source Code Expand
#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const long long inf = 1e18;
int qn, tot;
long long n, m, fib[100];
vector<pair<long long, long long> > a[100];
int main() {
fib[0] = fib[1] = 1;
tot = 1;
while (1) {
fib[tot + 1] = fib[tot] + fib[tot - 1];
if (fib[tot + 1] > inf) break;
++tot;
}
a[1].push_back(make_pair(1, 2));
a[1].push_back(make_pair(1, 3));
a[1].push_back(make_pair(1, 4));
for (int i = 1; i < tot - 2; ++i) {
vector<pair<long long, long long> >::iterator it;
for (it = a[i].begin(); it != a[i].end(); ++it) {
long long x = it->first, y = it->second;
x += y;
while (x <= fib[i + 3] + fib[i]) {
a[i + 1].push_back(make_pair(y, x));
x += y;
}
}
}
for (scanf("%d", &qn); qn; --qn) {
scanf("%lld%lld", &n, &m);
if (n > m) swap(n, m);
int ans_max = 1;
while (fib[ans_max + 1] <= n && fib[ans_max + 2] <= m) ++ans_max;
printf("%d ", ans_max);
if (ans_max == 1)
printf("%d\n", static_cast<int>(n * m % mod));
else {
long long cnt = 0;
vector<pair<long long, long long> >::iterator it;
for (it = a[ans_max - 1].begin(); it != a[ans_max - 1].end(); ++it) {
long long x = it->first, y = it->second;
if (y <= n) (cnt += (m - x) / y) %= mod;
if (y <= m) (cnt += (n - x) / y) %= mod;
}
printf("%d\n", static_cast<int>(cnt % mod));
}
}
}
Submission Info
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:33:23: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
for (scanf("%d", &qn); qn; --qn) {
^
./Main.cpp:34:28: 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 |
|
|
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 |
314 ms |
3328 KB |
02.txt |
AC |
314 ms |
3328 KB |
03.txt |
AC |
309 ms |
3328 KB |
04.txt |
AC |
309 ms |
3328 KB |
05.txt |
AC |
314 ms |
3328 KB |
06.txt |
AC |
309 ms |
3328 KB |
07.txt |
AC |
309 ms |
3328 KB |
08.txt |
AC |
309 ms |
3328 KB |
09.txt |
AC |
308 ms |
3328 KB |
10.txt |
AC |
309 ms |
3328 KB |
11.txt |
AC |
579 ms |
1920 KB |
12.txt |
AC |
580 ms |
2048 KB |
13.txt |
AC |
210 ms |
1920 KB |
14.txt |
AC |
210 ms |
1920 KB |
15.txt |
AC |
235 ms |
4096 KB |
16.txt |
AC |
236 ms |
4096 KB |
17.txt |
AC |
143 ms |
3840 KB |
18.txt |
AC |
144 ms |
3840 KB |
19.txt |
AC |
520 ms |
3584 KB |
20.txt |
AC |
518 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 |