Codeforces Round #209 (Div. 2) C. Prime Number_html/css_WEB-ITnose

WBOY
Release: 2016-06-24 12:04:22
Original
1120 people have browsed it

tTitle: http://codeforces.com/problemset/problem/359/C

n Many WA............ ............My coding ability is still very problematic.............

Summarize the status of your own code writing:
1. Start writing without clarifying your ideas...

2. When troubleshooting, you should organize your own logic. , see if the code expresses its own logic clearly

3. When looking at other people’s code, don’t always think that you can’t understand it, then you must not understand it. Think about it, especially under simulation, try Try to understand.

4. When troubleshooting, don’t just re-run the program with a slight change. This takes a lot of time. If you are basically sure that there is nothing that can be changed, run it again

5. Don’t stare at your own ideas. After WA is lost, try to think outside of your original ideas and try


GCD power is between sum-pri[n]-sum time, the number of enumerations, the loop written is still OK, take a closer look-------In fact, my coding ability is not good enough, and it is difficult to express what I want to do in code

#include <iostream>#include <cstdio>#include <cstring>#include <algorithm>#include <climits>#include <cmath>using namespace std;#define ll long longconst ll MOD = 1000000007;const int SIZE = 1e5+10;ll num[SIZE];ll Qmod(ll base,ll n){    ll ret=1;    while(n)    {        if(n&1)          ret=ret*base%MOD;        base=base*base%MOD;        n>>=1;    }    return ret;}int main(){    ll x,sum,tmpn;    ll n;    while(scanf("%I64d%I64d",&n,&x)!=EOF)    {        scanf("%I64d",&num[1]);        sum=num[1];        for(ll i=2;i<=n;i++)        {            scanf("%I64d",&num[i]);            sum+=num[i];        }        tmpn=sum-num[n];        for(ll p=num[n],cc=0;p>0;p--)        {            while(n&&num[n]==p)            {                n--;                cc++;//1的个数            }            if(cc%x)break;            tmpn++;            cc/=x;        }        printf("%I64d\n",Qmod(x,tmpn));    }    return 0;}
Copy after login


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template