Codeforces Round #209 (Div. 2)C
刷了一页的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的更多相关文章
- Codeforces Round #209 (Div. 2) B. Permutation
解题思路: 如果序列a是单调递增的,则序列为1,2,..... 2n,则将给出的式子化简得Σ(a2i - a2i-1) = n 如果序列a是单调递减的,则序列为2n,.........2, 1,则将给 ...
- Codeforces Round #209 (Div. 2) A. Table
#include <iostream> #include <vector> using namespace std; int main(){ int n,m; cin > ...
- Codeforces Round #209 (Div. 2)
A: 要么是两次要么4次,判断是否在边界: #include<cstdio> using namespace std; int main() { int n,m,x; ; scanf(&q ...
- 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 ...
- 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 ...
- 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} ...
- 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 ...
- Codeforces Round #354 (Div. 2) ABCD
Codeforces Round #354 (Div. 2) Problems # Name A Nicholas and Permutation standard input/out ...
- Codeforces Round #368 (Div. 2)
直达–>Codeforces Round #368 (Div. 2) A Brain’s Photos 给你一个NxM的矩阵,一个字母代表一种颜色,如果有”C”,”M”,”Y”三种中任意一种就输 ...
随机推荐
- 使用微信JSSDK自定义分享内容
微信在6.0.2.58版本以后开始使用新的api,在Android系统中不能用以前的代码来自定义分享内容了. 现在自定义内容的方法走的是公众号的一套流程 1获取access_token 2得到toke ...
- p3p之讲解
P3P是一种被称为个人隐私安全平台项目(the Platform for Privacy Preferences)的标准,能够保护在线隐私权,使Internet冲浪者可以选择在浏览网页时,是否被第三方 ...
- google大赛 入围赛250分真题
Problem StatementYou have a collection of music files with names formatted as "genre-artist-alb ...
- AngularJs学习笔记--concepts(概念)
原版地址:http://code.angularjs.org/1.0.2/docs/guide/concepts 继续.. 一.总括 本文主要是angular组件(components)的概览,并说明 ...
- doctype声明、浏览器的标准、怪异等模式
doctype 标准(严格)模式(Standards Mode).怪异(混杂)模式(Quirks Mode),如何触发,区分他们有何意义? 触发标准模式 1.加DOCTYPE声明,比如:<!DO ...
- MVC模式在游戏开发的应用
原地址: http://www.cocoachina.com/gamedev/2012/1129/5212.html MVC是三个单词的缩写,分别为:模型(Model).视图(View)和控制Cont ...
- 解决Flash和html在多标签浏览器中互访问题
在Flash播放器运行时,将不同来源的资源划分到独立的沙箱(sandbox)内,不同沙箱之间不能 彼此操作数据(除非目标沙箱做过一些设置,授权其他沙箱可访问),这就是Flash的跨沙箱问题.当Flas ...
- AIZU 2251
Merry Christmas Time Limit : 8 sec, Memory Limit : 65536 KB Problem J: Merry Christmas International ...
- Windows Server2008+IIS7部署网站的日期格式问题
最近部署一个ASP网站,发现网站的某个功能上的日历在原来的服务器上访问时是会根据特定日期来对该日进行加粗加红显示的,但部署到我公司机房的win2008服务器上访问时却没有这效果了. 于是通过本地部署, ...
- 深入浅出ES6(十五):子类 Subclassing
作者 Jason Orendorff github主页 https://github.com/jorendorff 在之前的文章<深入浅出ES6(十三):类 Class>中,我们一起深 ...