首页 web前端 html教程 Codeforces Round #279 (Div. 2) (C题)_html/css_WEB-ITnose

Codeforces Round #279 (Div. 2) (C题)_html/css_WEB-ITnose

Jun 24, 2016 am 11:53 AM

C. Hacking Cypher

time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

Polycarpus participates in a competition for hacking into a new secure messenger. He's almost won.

Having carefully studied the interaction protocol, Polycarpus came to the conclusion that the secret key can be obtained if he properly cuts the public key of the application into two parts. The public key is a long integer which may consist of even a million digits!

Polycarpus needs to find such a way to cut the public key into two nonempty parts, that the first (left) part is divisible by a as a separate number, and the second (right) part is divisible by b as a separate number. Both parts should be positive integers that have no leading zeros. Polycarpus knows values a and b.

Help Polycarpus and find any suitable method to cut the public key.

Input

The first line of the input contains the public key of the messenger ? an integer without leading zeroes, its length is in range from 1 to106 digits. The second line contains a pair of space-separated positive integers a, b (1?≤?a,?b?≤?108).

Output

In the first line print "YES" (without the quotes), if the method satisfying conditions above exists. In this case, next print two lines ? the left and right parts after the cut. These two parts, being concatenated, must be exactly identical to the public key. The left part must be divisible by a, and the right part must be divisible by b. The two parts must be positive integers having no leading zeros. If there are several answers, print any of them.

If there is no answer, print in a single line "NO" (without the quotes).

Sample test(s)

input

11640102497 1024
登录后复制

output

YES116401024
登录后复制

input

2842545891539281719112818110001009 1000
登录后复制

output

YES284254589153928171911281811000
登录后复制

input

12012 1
登录后复制

output

NO
登录后复制


又一次借鉴了袁学长的代码....

还是自己太菜了,啥都不咋会...

不过这次又学了好多....

比如怎么判断一个大数能否被一个数a整除

本题题意:就是去算出前一段能否整除a的同时能否使得后一段能整除b

思路:从前到后扫一遍记录前一段可以整除a的位置,从后到前扫一遍,如果后一段有可以整除b的位置,且前一段能整除a,就跳出循环,再输出,否则输出NO


判断一个大数num[1000010]能否被一个数a整除,代码:

#include <cstdio>#include <cstring>#include <iostream>using namespace std;int main(){	char num[1000010];	int a;	while(scanf("%s", num)!=EOF)	{		scanf("%d", &a);		int cur = 0;		for(int i=0; i<strlen i cur num a if else cout return>  <br>  <br>  <p></p>  <p><strong>AC代码:</strong></p>  <p><strong></strong></p>  <pre name="code" class="sycode">#include <cstdio>#include <cstring>#include <algorithm>using namespace std;const int maxn = 1000010;char num[maxn];bool jud[maxn];int main(){	while(scanf("%s", num)!=EOF)	{		int a, b;		scanf("%d %d", &a, &b);				memset(jud, 0, sizeof(jud));		//记录可以使前一段整除a的位置 		int len = strlen(num);		int cur = 0;		for(int i=0; i<len i cur num a if jud bool ok="0;" int k="1," pos for>=0; i--)		{			cur+=(num[i]-'0')*k;			cur%=b;			if(cur==0 && jud[i-1] &&num[i]!='0')			{				ok = 1;				pos = i;				break;			}			k*=10;			k%=b;		}		//输出答案 		if(ok)		{			printf("YES\n");			for(int i=0; i<pos-1 i printf num for else return>  <br>  <br>  <p></p>  <p><br> </p>  <p><br> </p>  <p><br> </p> </pos-1></len></algorithm></cstring></cstdio>
登录后复制
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn

热AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover

AI Clothes Remover

用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool

Undress AI Tool

免费脱衣服图片

Clothoff.io

Clothoff.io

AI脱衣机

Video Face Swap

Video Face Swap

使用我们完全免费的人工智能换脸工具轻松在任何视频中换脸!

热工具

记事本++7.3.1

记事本++7.3.1

好用且免费的代码编辑器

SublimeText3汉化版

SublimeText3汉化版

中文版,非常好用

禅工作室 13.0.1

禅工作室 13.0.1

功能强大的PHP集成开发环境

Dreamweaver CS6

Dreamweaver CS6

视觉化网页开发工具

SublimeText3 Mac版

SublimeText3 Mac版

神级代码编辑软件(SublimeText3)

HTML容易为初学者学习吗? HTML容易为初学者学习吗? Apr 07, 2025 am 12:11 AM

HTML适合初学者学习,因为它简单易学且能快速看到成果。1)HTML的学习曲线平缓,易于上手。2)只需掌握基本标签即可开始创建网页。3)灵活性高,可与CSS和JavaScript结合使用。4)丰富的学习资源和现代工具支持学习过程。

HTML,CSS和JavaScript的角色:核心职责 HTML,CSS和JavaScript的角色:核心职责 Apr 08, 2025 pm 07:05 PM

HTML定义网页结构,CSS负责样式和布局,JavaScript赋予动态交互。三者在网页开发中各司其职,共同构建丰富多彩的网站。

HTML中起始标签的示例是什么? HTML中起始标签的示例是什么? Apr 06, 2025 am 12:04 AM

AnexampleOfAstartingTaginHtmlis,beginSaparagraph.startingTagSareEssentialInhtmlastheyInitiateEllements,defiteTheeTheErtypes,andarecrucialforsstructuringwebpages wepages webpages andConstructingthedom。

了解HTML,CSS和JavaScript:初学者指南 了解HTML,CSS和JavaScript:初学者指南 Apr 12, 2025 am 12:02 AM

WebDevelovermentReliesonHtml,CSS和JavaScript:1)HTMLStructuresContent,2)CSSStyleSIT和3)JavaScriptAddSstractivity,形成thebasisofmodernWebemodernWebExexperiences。

Gitee Pages静态网站部署失败:单个文件404错误如何排查和解决? Gitee Pages静态网站部署失败:单个文件404错误如何排查和解决? Apr 04, 2025 pm 11:54 PM

GiteePages静态网站部署失败:404错误排查与解决在使用Gitee...

网页批注如何实现Y轴位置的自适应布局? 网页批注如何实现Y轴位置的自适应布局? Apr 04, 2025 pm 11:30 PM

网页批注功能的Y轴位置自适应算法本文将探讨如何实现类似Word文档的批注功能,特别是如何处理批注之间的间�...

如何用CSS3和JavaScript实现图片点击后周围图片散开并放大效果? 如何用CSS3和JavaScript实现图片点击后周围图片散开并放大效果? Apr 05, 2025 am 06:15 AM

实现图片点击后周围图片散开并放大效果许多网页设计中,需要实现一种交互效果:点击某张图片,使其周围的...

HTML,CSS和JavaScript:Web开发人员的基本工具 HTML,CSS和JavaScript:Web开发人员的基本工具 Apr 09, 2025 am 12:12 AM

HTML、CSS和JavaScript是Web开发的三大支柱。1.HTML定义网页结构,使用标签如、等。2.CSS控制网页样式,使用选择器和属性如color、font-size等。3.JavaScript实现动态效果和交互,通过事件监听和DOM操作。

See all articles