Submission #1844499


Source Code Expand

#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
//---------------------------------------------------------------------------------------------------
typedef long long ll;
ll gcd(ll a, ll b) { return a ? gcd(b%a, a) : b; }
/*---------------------------------------------------------------------------------------------------
            ∧_∧  
      ∧_∧  (´<_` )  Welcome to My Coding Space!
     ( ´_ゝ`) /  ⌒i     
    /   \     | |     
    /   / ̄ ̄ ̄ ̄/  |  
  __(__ニつ/     _/ .| .|____  
     \/____/ (u ⊃  
---------------------------------------------------------------------------------------------------*/



ll A, B;
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> A >> B;

    vector<ll> v[2];
    for (ll x = A; x <= B; x++) v[x % 2].push_back(x);

    int n = v[1].size(); int m = v[0].size();
    int ans = 0;
    rep(msk, 0, 1 << n) {
        vector<ll> x;
        rep(i, 0, n) if (msk & (1 << i)) x.push_back(v[1][i]);
        int ok = 1;
        int nm = x.size();
        rep(i, 0, nm) rep(j, i + 1, nm) if (gcd(x[i], x[j]) != 1) ok = 0;
        if (ok) ans++;
        else continue;

        rep(mm, 0, m) {
            int ok = 1;
            rep(i, 0, nm) if (gcd(x[i], v[0][mm]) != 1) ok = 0;
            if (ok) ans++;
        }
    }
    cout << ans << endl;
}

Submission Info

Submission Time
Task C - すぬけそだて――ごはん――
User hamayanhamayan
Language C++14 (GCC 5.4.1)
Score 400
Code Size 1794 Byte
Status AC
Exec Time 738 ms
Memory 256 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 3
AC × 18
Set Name Test Cases
Sample s1.txt, s2.txt, s3.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, s1.txt, s2.txt, s3.txt
Case Name Status Exec Time Memory
01.txt AC 1 ms 256 KB
02.txt AC 1 ms 256 KB
03.txt AC 684 ms 256 KB
04.txt AC 683 ms 256 KB
05.txt AC 335 ms 256 KB
06.txt AC 484 ms 256 KB
07.txt AC 1 ms 256 KB
08.txt AC 3 ms 256 KB
09.txt AC 335 ms 256 KB
10.txt AC 694 ms 256 KB
11.txt AC 695 ms 256 KB
12.txt AC 325 ms 256 KB
13.txt AC 660 ms 256 KB
14.txt AC 725 ms 256 KB
15.txt AC 738 ms 256 KB
s1.txt AC 1 ms 256 KB
s2.txt AC 1 ms 256 KB
s3.txt AC 687 ms 256 KB