刷了一页的WA  。。终于发现了 哪里错了 快速幂模板里一个变量t居然开得long  ...

虽然代码写的丑了点 但是是对的 那个该死的long 啊..

 #include <iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<stdlib.h>
#include<vector>
using namespace std;
#define mod 1000000007
#define LL __int64
#define N 100010
LL n,x,a[N],s,b[N];
LL exp_mod(LL a,LL n,LL b)
{
long long t;
if(n==) return %b;
if(n==) return a%b;
t=exp_mod(a,n/,b);
t=t*t%b;
if((n&)==) t=t*a%b;
return t;
}
int main()
{
int i;
cin>>n>>x;
for(i = ; i <= n ; i++)
{
scanf("%I64d",&a[i]);
s = s+a[i];
b[i] = a[i];
}
for(i = ; i <= n ; i++)
{
b[i] = s-a[n-i+];
}
for(i = ; i <= n ;i++)
a[i] = b[i];
LL k = a[];
int o = ;LL ss=a[];
LL sum=;
b[]-=a[];
while()
{
if(b[o]==&&o<=n)
{
o++;
b[o]-=a[o-];
sum++;
if(o>n) break;
else
continue;
}
if(o>n) break;
if(sum%x!=) break;
while(sum%x==&&o<=n)
{
sum/=x;
ss++;
b[o]--;
if(b[o]==)
{
o++;
b[o]-=a[o-];
sum++;
break;
}
}
if(o>n) break;
}
while(sum&&sum%x==)
{
ss+=;
sum/=x;
}
printf("%I64d\n",exp_mod(x,min(s,ss),mod));
return ;
}

Codeforces Round #209 (Div. 2)C的更多相关文章

  1. Codeforces Round #209 (Div. 2) B. Permutation

    解题思路: 如果序列a是单调递增的,则序列为1,2,..... 2n,则将给出的式子化简得Σ(a2i - a2i-1) = n 如果序列a是单调递减的,则序列为2n,.........2, 1,则将给 ...

  2. Codeforces Round #209 (Div. 2) A. Table

    #include <iostream> #include <vector> using namespace std; int main(){ int n,m; cin > ...

  3. Codeforces Round #209 (Div. 2)

    A: 要么是两次要么4次,判断是否在边界: #include<cstdio> using namespace std; int main() { int n,m,x; ; scanf(&q ...

  4. Codeforces Round #209 (Div. 2)A贪心 B思路 C思路+快速幂

    A. Table time limit per test 1 second memory limit per test 256 megabytes input standard input outpu ...

  5. Codeforces Round #209 (Div. 2) D. Pair of Numbers (模拟)

    D. Pair of Numbers time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

  6. Codeforces Round #209 (Div. 2) C - Prime Number

    传送门 题意 给出n个数及x,求 \[\frac{\sum _{i=1}^n x^{a_1+a_2+...+a_{i-1}+a_{i+1}+...a_n}}{\prod_{i=1}^n x^{a_i} ...

  7. Codeforces Round #366 (Div. 2) ABC

    Codeforces Round #366 (Div. 2) A I hate that I love that I hate it水题 #I hate that I love that I hate ...

  8. Codeforces Round #354 (Div. 2) ABCD

    Codeforces Round #354 (Div. 2) Problems     # Name     A Nicholas and Permutation standard input/out ...

  9. Codeforces Round #368 (Div. 2)

    直达–>Codeforces Round #368 (Div. 2) A Brain’s Photos 给你一个NxM的矩阵,一个字母代表一种颜色,如果有”C”,”M”,”Y”三种中任意一种就输 ...

随机推荐

  1. GS界面上显示的重要参考数据

    GS界面上显示的重要参考数据,这个是压测时重要参考 struct GSinfo { int revBuffNum; int sendBuffNum; int clientNum; int dbAskN ...

  2. JS中函数的基础知识

    函数 一.  函数定义 函数又叫方法,在程序里面函数是用来执行某些特定功能的代码.为了减少重复使用代码,可以把特定功能的代码做成函数,需要使用时拿出来调用.alert();就是一个很常见的.简单的函数 ...

  3. openOffice将doc在线预览

    最近,有个项目要用到类似DOCIN的文档转换和阅读的功能,于是就开始找相关的资料,最后总结出2种解决办法,以下就来探讨下两种方法的各自实现. 第一种:通过FLASH PAPER来转换DOC文档直接生成 ...

  4. 使用feof()函数判断文件是否结束

    课本上时这样写的:(用putchar(ch);代表对取出来的字符的处理.) while(!feof(fp)) { ch=fgetc(fp); putchar(ch); } 但是,这样写的话,fgetc ...

  5. 迁移到MariaDB galera

    迁移到MariaDB galera [已注销] [已注销] -- :: [安装] ====== https://downloads.mariadb.org/mariadb/repositories/ ...

  6. HTML5程序设计--SVG

    SVG(Scalable Vector Graphics):可缩放矢量图形,一种二维图形表示语言. 借助SVG,我们可以实现很多同Canvas API类型的绘制操作,但在Canvas元素上绘制文本的时 ...

  7. SQl 字段中出现某一个词语的次数

    select length(f3) - length(replace(f3, 'a','')) from t1 简单的,如果,要统计 good 出现的次数,改成 select (length(f3) ...

  8. DevExpress GridView 自定义搜索按钮改为中文内容

    首先将 GridControl 控件的搜索功能显示出来. http://www.cnblogs.com/DeepLearing/p/3887601.html 显示效果如下: 可以通过 GridLoca ...

  9. MySQL 5.1参考手册

    目录 前言 1. 一般信息 1.1. 关于本手册 1.2. 本手册采用的惯例 1.3. MySQL AB概述 1.4. MySQL数据库管理系统概述 1.4.1. MySQL的历史 1.4.2. My ...

  10. 在 eclipse 中设置每行的字数

    在Preferences中:Java Code Style Formatter