Codeforces Round #279 (Div. 2) C. Hacking Cypher 机智的前缀和处理
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <sstream>
#include <queue>
#include <typeinfo>
#include <fstream>
typedef long long ll;
using namespace std;
//freopen("D.in","r",stdin);
//freopen("D.out","w",stdout);
#define io_speed ios_base::sync_with_stdio(0);cin.tie(0)
string s;
int a,b,vis[];
int main(){
io_speed;
cin>>s;
cin>>a>>b;
int base=,ans=,len = s.size();
memset(vis,,sizeof(vis));
for(int i=len-;i>;i--){
ans = ( ans + (s[i] - '')*base ) % b;
vis[i] = ans;
base = base*%b;
}
ans=;
for(int i=;i<len-;i++){
ans = ( ans* + s[i]-'' ) % a;
if( ans== && vis[i+]== && s[i+]!='' ){
cout<<"YES\n";
cout<<s.substr(,i+)<<endl;
cout<<s.substr(i+,len-i-)<<endl;
return ;
}
}
puts("NO");
return ;
}
Codeforces Round #279 (Div. 2) C. Hacking Cypher 机智的前缀和处理的更多相关文章
- Codeforces Round #279 (Div. 2) C. Hacking Cypher 前缀+后缀
C. Hacking Cypher time limit per test 1 second memory limit per test 256 megabytes input standard in ...
- Codeforces Round #279 (Div. 2) C. Hacking Cypher (大数取余)
题目链接 C. Hacking Cyphertime limit per test1 secondmemory limit per test256 megabytesinputstandard inp ...
- Codeforces Round #279 (Div. 2) ABCDE
Codeforces Round #279 (Div. 2) 做得我都变绿了! Problems # Name A Team Olympiad standard input/outpu ...
- Codeforces Round #279 (Div. 2) 题解集合
终于有场正常时间的比赛了...毛子换冬令时还正是好啊233 做了ABCD,E WA了3次最后没搞定,F不会= = 那就来说说做的题目吧= = A. Team Olympiad 水题嘛= = 就是个贪心 ...
- Codeforces Round #279 (Div. 2) vector
A. Team Olympiad time limit per test 1 second memory limit per test 256 megabytes input standard inp ...
- Codeforces Round #279 (Div. 2) E. Restoring Increasing Sequence 二分
E. Restoring Increasing Sequence time limit per test 1 second memory limit per test 256 megabytes in ...
- CodeForces Round #279 (Div.2)
A: 题意: 有三个项目和n个学生,每个学生都擅长其中一个项目,现在要组成三个人的队伍,其中每个人恰好擅长其中一门,问能组成多少支队伍. 分析: 最多能组成的队伍的个数就是擅长项目里的最少学生. #i ...
- 【Codeforces Round#279 Div.2】B. Queue
这题看别人的.就是那么诚实.http://www.cnblogs.com/zhyfzy/p/4117481.html B. Queue During the lunch break all n Ber ...
- Codeforces Round #279 (Div. 2)f
树形最大上升子序列 这里面的上生子序列logn的地方能当模板使 good #include<iostream> #include<string.h> #include< ...
随机推荐
- MySQL参数设置
InnoDB配置 从MySQL 5.5版本开始,InnoDB就是默认的存储引擎并且它比任何其它存储引擎的使用要多得多.那也是为什么它需要小心配置的原因. 1 innodb_file_per_table ...
- C# 日文网址转punnycode
Uri uri = new Uri(url); IdnMapping idn = new IdnMapping();url= url.Replace(uri.Host, idn.GetAscii(ur ...
- MongoDB的安装与使用
MongoDB是一款NoSql数据库.NoSql数据库叫非关系型数据库,NoSql的全名Not only sql.是为了解决高并发.高可用.高可扩展,以及大数据存储等一系列问题而产生的数据库解决方案. ...
- 常见四大类型视频接线DP、HDMI、DVI、VGA的比较
如今是新的“视”界,生活中总与各种屏幕打交道,难免会遇到选择视频接线的问题,要想搞清楚这点,我们只要通过了解现今常用的几种视频接线就会有个大致的认识. 281VGA.DVI.HDMI三种视频信号接 ...
- django(1)安装及配置
1.版本选择 Django 1.5.x 支持 Python 2.6.5 Python 2.7, Python 3.2 和 3.3. Django 1.6.x 支持 Python 2.6.X, 2.7. ...
- xss攻击原理与解决方法
概述 XSS攻击是Web攻击中最常见的攻击方法之一,它是通过对网页注入可执行代码且成功地被浏览器 执行,达到攻击的目的,形成了一次有效XSS攻击,一旦攻击成功,它可以获取用户的联系人列 表,然后向联系 ...
- CCF CSP 201503-1 图像旋转
CCF计算机职业资格认证考试题解系列文章为meelo原创,请务必以链接形式注明本文地址 CCF CSP 201503-1 图像旋转 问题描述 旋转是图像处理的基本操作,在这个问题中,你需要将一个图像逆 ...
- day5模块学习--hashlib模块
hashlib模块 Python的hashlib提供了常见的摘要算法,如MD5,SHA1等等. 什么是摘要算法呢?摘要算法又称哈希算法.散列算法.它通过一个函数,把任意长度的数据转换为一个长度 ...
- MFC+WinPcap编写一个嗅探器之一(准备)
知识准备: MFC:http://www.jizhuomi.com/software/257.html WinPcap:http://www.ferrisxu.com/WinPcap/html/ind ...
- 老的API实现WordCount
使用Hadoop版本0.x实现单词统计 package old; import java.io.IOException; import java.net.URI; import java.util.I ...