• Aladdin and the Flying Carpet


    Aladdin and the Flying Carpet

    https://cn.vjudge.net/contest/288520#problem/C

    It's said that Aladdin had to solve seven mysteries before getting the Magical Lamp which summons a powerful Genie. Here we are concerned about the first mystery.

    Aladdin was about to enter to a magical cave, led by the evil sorcerer who disguised himself as Aladdin's uncle, found a strange magical flying carpet at the entrance. There were some strange creatures guarding the entrance of the cave. Aladdin could run, but he knew that there was a high chance of getting caught. So, he decided to use the magical flying carpet. The carpet was rectangular shaped, but not square shaped. Aladdin took the carpet and with the help of it he passed the entrance.

    Now you are given the area of the carpet and the length of the minimum possible side of the carpet, your task is to find how many types of carpets are possible. For example, the area of the carpet 12, and the minimum possible side of the carpet is 2, then there can be two types of carpets and their sides are: {2, 6} and {3, 4}.

    Input

    Input starts with an integer T (≤ 4000), denoting the number of test cases.

    Each case starts with a line containing two integers: a b (1 ≤ b ≤ a ≤ 1012) where a denotes the area of the carpet and b denotes the minimum possible side of the carpet.

    Output

    For each case, print the case number and the number of possible carpets.

    Sample Input

    2

    10 2

    12 2

    Sample Output

    Case 1: 1

    Case 2: 2

    唯一分解定理

    当tmp>1时,根据它的因子是1,所以要乘上(1+1)(这是我的理解方法。。。有错的话麻烦各位大佬指出

     1 #include<bits/stdc++.h>
     2 using namespace std;
     3 #define lson l,mid,rt<<1
     4 #define rson mid+1,r,rt<<1|1
     5 #define sqr(x) ((x)*(x))
     6 #define pb push_back
     7 #define eb emplace_back
     8 #define maxn 1000005
     9 #define eps 1e-8
    10 #define pi acos(-1.0)
    11 #define rep(k,i,j) for(int k=i;k<j;k++)
    12 typedef long long ll;
    13 typedef pair<int,int> pii;
    14 typedef pair<long long,int>pli;
    15 typedef pair<int,char> pic;
    16 typedef pair<pair<int,string>,pii> ppp;
    17 typedef unsigned long long ull;
    18 const long long mod=1e9+7;
    19 /*#ifndef ONLINE_JUDGE
    20         freopen("1.txt","r",stdin);
    21 #endif */
    22 
    23 int phi[maxn];
    24 bool vis[maxn];
    25 int prime[maxn];
    26 int tot;
    27 
    28 void Init(int n){
    29     phi[1]=1;
    30     for(int i=2;i<=n;i++){
    31         if(!vis[i]){
    32             prime[++tot]=i;
    33             phi[i]=i-1;
    34         }
    35         for(int j=1;j<=tot&&i*prime[j]<=n;j++){
    36             vis[i*prime[j]]=true;
    37             if(i%prime[j]==0){
    38                 phi[i*prime[j]]=phi[i]*prime[j];
    39                 break;
    40             }
    41             phi[i*prime[j]]=phi[i]*(prime[j]-1);
    42         }
    43     }
    44 }
    45 
    46 int main(){
    47     #ifndef ONLINE_JUDGE
    48      //   freopen("1.txt","r",stdin);
    49     #endif
    50     std::ios::sync_with_stdio(false);
    51     int t;
    52     Init(maxn-1);
    53     cin>>t;
    54     for(int _=1;_<=t;_++){
    55         ll a,b;
    56 
    57         cin>>a>>b;
    58         ll tmp=a;
    59         ll ans=1;
    60         if(a<b*b){
    61             cout<<"Case "<<_<<": "<<0<<endl;
    62             continue;
    63         }
    64         for(ll i=1;i<=tot&&prime[i]*prime[i]<=tmp;i++){
    65             if(tmp%prime[i]==0){
    66                 ll co=0;
    67                 while(tmp%prime[i]==0){
    68                     co++;
    69                     tmp/=prime[i];
    70                 }
    71                 co++;
    72                 ans*=co;
    73             }
    74         }
    75         if(tmp>1) ans*=(1+1);
    76         ans/=2;
    77         for(ll i=1;i<b;i++){
    78             if(a%i==0) ans--;
    79         }
    80         cout<<"Case "<<_<<": "<<ans<<endl;
    81 
    82     }
    83 
    84 }
    View Code
  • 相关阅读:
    iOS 解析xml
    带滚动条html,js获取鼠标位置
    iOS ViewController利用代理页面传值
    Android Volley完全解析
    32位linux中无法使用AVD的解决方案
    8年前在公交上被年轻小伙打了,76岁大爷苦练功夫“复仇”成功...网友:大爷,你一定是天蝎座的吧
    退学,离家出走,卖房创业,在他即将烧完最后一笔钱时,获250万元融资
    夏普将在迪拜推出植物工厂种草莓
    国产手机出货量今年要追平苹果三星,到底有多难?
    原生ajax动态添加数据
  • 原文地址:https://www.cnblogs.com/Fighting-sh/p/10544144.html
Copyright © 2020-2023  润新知