zoukankan      html  css  js  c++  java
  • CF789B. Masha and geometric depression

      1 /*
      2  CF789B. Masha and geometric depression
      3  http://codeforces.com/contest/789/problem/B
      4  水题
      5  各种特判,贼烦
      6  */
      7 #include <cstdio>
      8 #include <algorithm>
      9 #include <cstring>
     10 #include <cmath>
     11 #include <vector>
     12 #include <queue>
     13 #include <map>
     14 #include <iostream>
     15 //#define test
     16 using namespace std;
     17 const int Nmax=1e6+7;
     18 long long num[Nmax];
     19 map<long long,int> f;
     20 int main()
     21 {
     22     #ifdef test
     23     #endif
     24     long long a,q,l;
     25     int m;
     26     scanf("%I64d%I64d%I64d%d",&a,&q,&l,&m);
     27     //cin>>a>>q>>l>>m;
     28     for(int i=1;i<=m;i++)
     29     {
     30         scanf("%I64d",&num[i]);
     31         f[ num[i] ]=1;
     32     }
     33     if(q==1LL)
     34     {
     35         if(abs(a)>abs(l))
     36         {
     37             printf("0
    ");
     38             return 0;
     39         }
     40         if(f[a]==1)
     41             printf("0
    ");
     42         else
     43             printf("inf
    ");
     44         return 0;
     45     }
     46     if(q==-1LL)
     47     {
     48         if(abs(a)>abs(l))
     49         {
     50             printf("0
    ");
     51             return 0;
     52         }
     53         if(f[a]==1 && f[-a]==1)
     54         {
     55             printf("0
    ");
     56             return 0;
     57         }
     58         else if(f[a]==0 && f[-a]==0)
     59         {
     60             printf("inf
    ");
     61             return 0;
     62         }
     63         else
     64         {
     65             printf("inf
    ");
     66             return 0;
     67         }
     68     }
     69     if(abs(a)>abs(l))
     70     {
     71         printf("0
    ");
     72         return 0;
     73     }
     74     if(q==0LL)
     75     {
     76         if(f[a]==0 && f[0]==1)
     77         {
     78             printf("1
    ");
     79             return 0;
     80         }
     81         if(f[a]==1 && f[0]==1)
     82         {
     83             printf("0
    ");
     84             return 0;
     85         }
     86         if(f[a]==0 && f[0]==0)
     87         {
     88             printf("inf
    ");
     89             return 0;
     90         }
     91         if(f[a]==1 && f[0]==0)
     92         {
     93             printf("inf
    ");
     94             return 0;
     95         }
     96         return 0;
     97     }
     98     if(a==0LL)
     99     {
    100         if(f[a]==1)
    101             printf("0
    ");
    102         else
    103             printf("inf
    ");
    104         return 0;
    105     }
    106     //if(abs(a)>abs(l) && f[a]==0)
    107     //{
    108         //printf("0
    ");
    109         //return 0;
    110     //}
    111     //if(abs(a*q)>abs(l) && f[a*q]==0)
    112     //{
    113         //printf("1
    ");
    114         //return 0;
    115     //}
    116     //else if(abs(a*q)>abs(l))
    117     //{
    118         //printf("0
    ");
    119         //return 0;
    120     //}
    121     //if(q==1LL || q==-1LL || q==0LL)
    122     //{
    123         //printf("inf
    ");
    124         //return 0;
    125     //}
    126     //if(a==0LL)
    127     //{
    128         //printf("inf
    ");
    129         //return 0;
    130     //}
    131     long long ans=0LL;
    132     while(1)
    133     {
    134         if(abs(a)>abs(l))
    135             break;
    136         //if(ans>=32LL)
    137         //{
    138             //printf("inf
    ");
    139             //return 0;
    140         //}
    141         if(f[a]==0)
    142             ans++;
    143         a*=q;
    144     }
    145     printf("%I64d
    ",ans);
    146     //cout<<ans<<endl;
    147     return 0;
    148 }
  • 相关阅读:
    docker常用命令
    Jenkins 插件开发记录
    【转】python作用域
    git备忘录
    【笔记】script.sh: source: not found in docker 问题
    (转)JavaScript判断浏览器类型及版本
    (转)webstorm快捷键
    (转)javaScript call 函数的用法说明
    (转载)记录函数 getStyle() 获取元素 CSS 样式
    (转)resize扩展
  • 原文地址:https://www.cnblogs.com/BBBob/p/6645444.html
Copyright © 2011-2022 走看看