QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#60631#1902. Computational ethnographywtcherr#WA 2ms3548kbC++202.6kb2022-11-05 20:13:382022-11-05 20:13:41

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 20:13:41]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3548kb
  • [2022-11-05 20:13:38]
  • 提交

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)
    {
        ll cnt = 0;
        for (ll i = 1; i * i <= x; i++)
        {
            string res = to_string(i * i);
            string revres = res;
            reverse(all(revres));
            if (res == revres)
            {
                cnt++;
                continue;
            }
            string tmpi = to_string(i);
            reverse(all(tmpi));
            ll tx = stoi(tmpi);
            string restx = to_string(tx * tx);
            string revrestx = restx;
            reverse(all(revrestx));
            if (restx == revres && revrestx == res)
                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();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 3284kb

input:

1
1000

output:

10

result:

ok 1 number(s): "10"

Test #2:

score: 0
Accepted
time: 0ms
memory: 3432kb

input:

20
40

output:

0

result:

ok 1 number(s): "0"

Test #3:

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

input:

80
100

output:

0

result:

ok 1 number(s): "0"

Test #4:

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

input:

1
1

output:

1

result:

ok 1 number(s): "1"

Test #5:

score: 0
Accepted
time: 1ms
memory: 3520kb

input:

10
20

output:

0

result:

ok 1 number(s): "0"

Test #6:

score: 0
Accepted
time: 0ms
memory: 3296kb

input:

16
90

output:

0

result:

ok 1 number(s): "0"

Test #7:

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

input:

18
86

output:

0

result:

ok 1 number(s): "0"

Test #8:

score: 0
Accepted
time: 0ms
memory: 3548kb

input:

10
61

output:

0

result:

ok 1 number(s): "0"

Test #9:

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

input:

239
1488

output:

4

result:

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