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”三种中任意一种就输 ...
随机推荐
- 土地购买 usaco 斜率优化
看这道题的时候,感觉很难,因为数据范围比较大,很难dp: 后来想到了[书柜的尺寸]这道题,也是一道dp,曾经看了那道题的题解而深有启发: 这道题每组的付费只与这一组长宽的最大值有关,也就是说要分组,一 ...
- js中的null VS undefined
var a;------>undefined. JS变量的默认值.注意点在于判断变量的值为null.这是错误的.比如 if( a === null ) { // TODO; }; 实际上是und ...
- Codeforces 322B
B. Ciel and Flowers time limit per test 1 second memory limit per test 256 megabytes input standard ...
- Sqli-labs less 27
Less-27 本关主要考察将union,select和26关过滤掉的字符.此处我们依旧和26关的方式是一样的,只需要将union和select改为大小写混合就可以突破. 示例:127.0.0.1/s ...
- Sqli-labs less 41
Less-41 此处与less-39是一致的,区别在于41错误不回显.所以我们称之为盲注. Payload: http://192.168.11.189/sqli-labs/Less-41/index ...
- POJ 3978 Primes(素数筛选法)
题目 简单的计算A,B之间有多少个素数 只是测试数据有是负的 //AC //A和B之间有多少个素数 //数据可能有负的!!! #include<string.h> #include< ...
- iOS验证码倒计时(GCD实现)
+ (void)verificationCode:(void(^)())blockYes blockNo:(void(^)(id time))blockNo { __block ; //倒计时时间 d ...
- 历代诗词咏宁夏注释3----蔡升元:<题大清渠>
题大清渠 蔡升元 为怜□□□□□,□□□□□□□. □□□□沙碛里,凿开峡口贺兰旁. 支分九堡通沟浍,鼎峙三渠并汉唐. 作吏尽如君任事,不难到处乐丰穰. 两渠中划大清渠,畚筑无劳民力纾.[1] 心画万 ...
- sql server 函数
1.Fun_Split 分割字符串,形成返回表 CREATE FUNCTION [dbo].[Fun_Split] ( @Items VARCHAR(MAX), @SplitStr VARCHAR(M ...
- C# WinForm窗口最小化到系统托盘
* C# WinForm窗口最小化到系统托盘http://hi.baidu.com/kfxtgtqyapouyze/item/8ccfdcd5a174a7312a35c7c3 主要功能:(1).程序启 ...