QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#60625#1902. Computational ethnographywtcherr#WA 2ms3532kbC++202.5kb2022-11-05 19:41:352022-11-05 19:41:36

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-11-05 19:41:36]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3532kb
  • [2022-11-05 19:41:35]
  • 提交

answer

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define f first
#define s second
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define IO ios_base::sync_with_stdio(0), cin.tie(0)
const int mod = 1e9 + 7;
template <typename T>
void readArray(vector<T> &A)
{
    for (T &i : A)
        cin >> i;
}
template <typename T>
void readArray(vector<vector<T>> &A)
{
    for (vector<T> &i : A)
        readArray(i);
}
template <typename T>
void printArray(vector<T> A)
{
    for (T i : A)
        cout << i << " ";
    cout << endl;
}
ll fastPow(ll a, ll b, ll m = mod)
{
    a %= m;
    ll res = 1;
    while (b > 0)
    {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}
bool isPrime(ll n, int iter = 5)
{
    if (n < 4)
        return n == 2 || n == 3;
    for (int i = 0; i < iter; i++)
    {
        int a = 2 + rand() % (n - 3);
        if (fastPow(a, n - 1, n) != 1)
            return false;
    }
    return true;
}
ll inv(ll n, ll m = mod)
{
    return fastPow(n, m - 2);
}
ll mul(ll a, ll b, ll m = mod)
{
    return (a * b) % m;
}
ll add(ll a, ll b, ll m = mod)
{
    return (a + b + m) % m;
}
void solve()
{
    ll A, B;
    cin >> A >> B;
    auto calc = [&](ll x)
    {
        int cnt = 0;
        for (ll i = 1; i * i <= x; i++)
        {
            string tmp = to_string(i);
            reverse(all(tmp));
            ll tx = stoi(tmp);
            string res = to_string(i * i);
            string revres = res;
            string txres = to_string(tx * tx);
            string revtx = txres;
            reverse(all(revres));
            if (revres == revtx || res == revres)
            {
                // cout << res << "\n";
                cnt++;
            }
        }
        return cnt;
    };
    // cout << calc(B) << " " << calc(A - 1) << "\n";
    cout << calc(B) - calc(A - 1);
}
void trials()
{
    int t, tt;
    for (cin >> t, tt = t; t--; cout << endl)
    {
        // cout << "Case #" << tt - t << ": ";
        solve();
    }
}
int main()
{
    // freopen("","r",stdin);
    IO;
    solve();
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3280kb

input:

1
1000

output:

10

result:

ok 1 number(s): "10"

Test #2:

score: 0
Accepted
time: 2ms
memory: 3404kb

input:

20
40

output:

0

result:

ok 1 number(s): "0"

Test #3:

score: 0
Accepted
time: 2ms
memory: 3484kb

input:

80
100

output:

0

result:

ok 1 number(s): "0"

Test #4:

score: 0
Accepted
time: 2ms
memory: 3532kb

input:

1
1

output:

1

result:

ok 1 number(s): "1"

Test #5:

score: 0
Accepted
time: 2ms
memory: 3484kb

input:

10
20

output:

0

result:

ok 1 number(s): "0"

Test #6:

score: 0
Accepted
time: 2ms
memory: 3484kb

input:

16
90

output:

0

result:

ok 1 number(s): "0"

Test #7:

score: 0
Accepted
time: 2ms
memory: 3348kb

input:

18
86

output:

0

result:

ok 1 number(s): "0"

Test #8:

score: 0
Accepted
time: 2ms
memory: 3348kb

input:

10
61

output:

0

result:

ok 1 number(s): "0"

Test #9:

score: -100
Wrong Answer
time: 2ms
memory: 3232kb

input:

239
1488

output:

4

result:

wrong answer 1st numbers differ - expected: '5', found: '4'