結果

問題 No.1567 Integer Coefficient Equation
ユーザー 👑 PCTprobabilityPCTprobability
提出日時 2021-04-18 14:21:45
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 252 ms / 2,000 ms
コード長 3,089 bytes
コンパイル時間 5,160 ms
コンパイル使用メモリ 262,184 KB
実行使用メモリ 9,492 KB
最終ジャッジ日時 2023-09-07 16:09:19
合計ジャッジ時間 14,978 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
9,252 KB
testcase_01 AC 75 ms
9,292 KB
testcase_02 AC 228 ms
9,208 KB
testcase_03 AC 226 ms
9,312 KB
testcase_04 AC 225 ms
9,412 KB
testcase_05 AC 227 ms
9,412 KB
testcase_06 AC 226 ms
9,192 KB
testcase_07 AC 76 ms
9,296 KB
testcase_08 AC 75 ms
9,408 KB
testcase_09 AC 76 ms
9,240 KB
testcase_10 AC 74 ms
9,184 KB
testcase_11 AC 75 ms
9,176 KB
testcase_12 AC 75 ms
9,384 KB
testcase_13 AC 75 ms
9,184 KB
testcase_14 AC 76 ms
9,480 KB
testcase_15 AC 76 ms
9,300 KB
testcase_16 AC 76 ms
9,180 KB
testcase_17 AC 249 ms
9,256 KB
testcase_18 AC 251 ms
9,416 KB
testcase_19 AC 248 ms
9,232 KB
testcase_20 AC 251 ms
9,440 KB
testcase_21 AC 251 ms
9,412 KB
testcase_22 AC 248 ms
9,256 KB
testcase_23 AC 251 ms
9,344 KB
testcase_24 AC 246 ms
9,184 KB
testcase_25 AC 245 ms
9,256 KB
testcase_26 AC 248 ms
9,236 KB
testcase_27 AC 247 ms
9,412 KB
testcase_28 AC 249 ms
9,192 KB
testcase_29 AC 252 ms
9,492 KB
testcase_30 AC 252 ms
9,296 KB
testcase_31 AC 250 ms
9,300 KB
testcase_32 AC 249 ms
9,312 KB
testcase_33 AC 252 ms
9,244 KB
testcase_34 AC 244 ms
9,236 KB
testcase_35 AC 248 ms
9,388 KB
testcase_36 AC 249 ms
9,412 KB
testcase_37 AC 245 ms
9,316 KB
testcase_38 AC 247 ms
9,492 KB
testcase_39 AC 235 ms
9,316 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#if __has_include(<atcoder/all>)
#include <atcoder/all>
using namespace atcoder;
#endif
using ll = long long;
using ld = long double;
using ull = long long;
#define REP3(i, m, n) for (int i = (m); (i) < int(n); ++ (i))
#define ALL(x) begin(x), end(x)
#define all(s) (s).begin(),(s).end()
#define rep2(i, m, n) for (int i = (m); i < (n); ++i)
#define rep(i, n) rep2(i, 0, n)
#define drep2(i, m, n) for (int i = (m)-1; i >= (n); --i)
#define drep(i, n) drep2(i, n, 0)
#define rever(vec) reverse(vec.begin(), vec.end())
#define sor(vec) sort(vec.begin(), vec.end())
#define fi first
#define se second
#define P pair<ll,ll>
#define REP(i, n) for (int i = 0; i < (n); ++i)
//const ll mod = 998244353;
const ll mod = 1000000007;
const ll inf = 2000000000000000000ll;
static const long double pi = 3.141592653589793;
template<class T>void vcin(vector<T> &n){for(int i=0;i<int(n.size());i++) cin>>n[i];}
template<class T>void vcout(vector<T> &n){for(int i=0;i<int(n.size());i++){cout<<n[i]<<" ";}cout<<endl;}
void YesNo(bool a){if(a){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}}
void YESNO(bool a){if(a){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}}
template<class T,class U> void chmax(T& t,const U& u){if(t<u) t=u;}
template<class T,class U> void chmin(T& t,const U& u){if(t>u) t=u;}
template<class T> void ifmin(T t,T u){if(t>u){cout<<-1<<endl;}else{cout<<t<<endl;}}
template<class T> void ifmax(T t,T u){if(t>u){cout<<-1<<endl;}else{cout<<t<<endl;}}
template<typename T,typename ...Args>auto make_vector(T x,int arg,Args ...args){if constexpr(sizeof...(args)==0)return vector<T>(arg,x);else return vector(arg,make_vector<T>(x,args...));}
ll modPow(ll a, ll n, ll mod) { ll ret = 1; ll p = a % mod; while (n) { if (n & 1) ret = ret * p % mod; p = p * p % mod; n >>= 1; } return ret; }

void gbjsmzmfuuvdf(){
  ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
  cout<< fixed << setprecision(20);
}
template<typename T>
vector<T> smallest_prime_factors(T n) {
  vector<T> spf(n+1);
  for(int i=0;i<=n;i++) spf[i]=i;
  for(T i=2;i*i<=n;i++){
    if(spf[i]==i){
      for(T j=i*i;j<=n;j+=i){
        if(spf[j]==j){
          spf[j]=i;
        }
      }
    }
  }
  return spf;
}
 
template<typename T>
vector<T> factolization(T x, vector<T> &spf) {
    vector<T> ret;
    while (x != 1) {
        ret.push_back(spf[x]);
        x /= spf[x];
    }
    sort(ret.begin(), ret.end());
    return ret;
}
int main() {
  gbjsmzmfuuvdf();
  auto s=smallest_prime_factors(600000);
  vector<ll> p(501000);
  for(int i=1;i<=500000;i++){
    auto v=factolization(i,s);
    if(v.size()>=3&&(v[0]!=v[1]||v[1]!=v[2]||v.size()>=4)){
      p[i]++;
    }
    p[i]+=p[i-1];
  }
  ll t;
  cin>>t;
  assert(1<=t&&t<=100000);
  while(t--){
    ll a,b,c;
    cin>>a>>b>>c;
    assert(abs(a)<=200000&&abs(b)<=200000&&abs(c)<=200000);
    b-=a;
    c-=a;
    if(b*c<0){
      cout<<1+p[abs(b)]+p[abs(c)]<<endl;
    }
    else if(b*c==0){
      cout<<1+p[max(abs(b),abs(c))]<<endl;
    }
    else{
      cout<<p[max(abs(b),abs(c))]-p[min(abs(b),abs(c))-1]<<endl;
    }
  }
}
0