Foj1675数论
http://acm.fzu.edu.cn/problem.php?pid=1675
首先必须知道一点数论的基本公式 (a-b) %c =0 -----> a%c=b%c
首先通过大数取余求出目标数值对77的余数,然后求出要求数值之后开始到最后的数值对于77取余得到的余数,满足条件然后输出结果;进行枚举就可以了。
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<iomanip> using namespace std;
double num[]={1.0,10.0,100.0,1000.0,10000.0,100000.0,1000000.0,10000000.0,100000000.0,1000000000.0,10000000000.0,
100000000000.0,1000000000000.0,10000000000000.0,100000000000000.0,1000000000000000.0}; int main()
{
__int64 i , j , k , x , y , len , temp , sum , sum1 , sum2 , sum3 ;
char str[ 1000005 ] ;
while( scanf( "%s" , str ) != EOF )
{
len = strlen( str ) ;
sum = sum2 = 0 ;
for( i = 0 ; str[ i ] ; ++i )
{
if( str[ i ] == 'x' )
{
sum = ( sum * 100 + 99 ) % 77 ;
break ;
}
sum = sum * 10 + ( str[ i ] - '0' ) ;
sum %= 77 ;
printf( "%c" , str[ i ] ) ;
}
for( j = i + 4 ; str[ j ] ; ++j )
{
sum2 = sum2 * 10 + ( str[ j ] - '0' ) ;
sum2 %= 77 ;
}
temp = len - i - 4 ;
for( k = 23 ; k <= 99 ; ++k )
{
sum1 = ( sum * 100 + k ) % 77 ;
for( x = 0 ; x <= temp / 15 + 1 ; ++x )
{
sum1 = sum1 * num[ 15 ] ;
sum1 %= 77 ;
}
sum1 = sum1 * num[ temp % 15 ] + sum2 ;
sum1 %= 77 ;
if( sum1 == 0 )
break ;
}
printf( "99%d" , k ) ;
for( y = i + 4 ; str[ y ] ; y++ )
printf( "%c" , str[ y ] ) ;
printf( "\n" );
}
return 0 ;
}
Foj1675数论的更多相关文章
- Codeforces Round #382 Div. 2【数论】
C. Tennis Championship(递推,斐波那契) 题意:n个人比赛,淘汰制,要求进行比赛双方的胜场数之差小于等于1.问冠军最多能打多少场比赛.题解:因为n太大,感觉是个构造.写写小数据, ...
- NOIP2014 uoj20解方程 数论(同余)
又是数论题 Q&A Q:你TM做数论上瘾了吗 A:没办法我数论太差了,得多练(shui)啊 题意 题目描述 已知多项式方程: a0+a1x+a2x^2+..+anx^n=0 求这个方程在[1, ...
- 数论学习笔记之解线性方程 a*x + b*y = gcd(a,b)
~>>_<<~ 咳咳!!!今天写此笔记,以防他日老年痴呆后不会解方程了!!! Begin ! ~1~, 首先呢,就看到了一个 gcd(a,b),这是什么鬼玩意呢?什么鬼玩意并不 ...
- hdu 1299 Diophantus of Alexandria (数论)
Diophantus of Alexandria Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java ...
- 【BZOJ-4522】密钥破解 数论 + 模拟 ( Pollard_Rho分解 + Exgcd求逆元 + 快速幂 + 快速乘)
4522: [Cqoi2016]密钥破解 Time Limit: 10 Sec Memory Limit: 512 MBSubmit: 290 Solved: 148[Submit][Status ...
- bzoj2219: 数论之神
#include <iostream> #include <cstdio> #include <cstring> #include <cmath> #i ...
- hdu5072 Coprime (2014鞍山区域赛C题)(数论)
http://acm.hdu.edu.cn/showproblem.php?pid=5072 题意:给出N个数,求有多少个三元组,满足三个数全部两两互质或全部两两不互质. 题解: http://dty ...
- ACM: POJ 1061 青蛙的约会 -数论专题-扩展欧几里德
POJ 1061 青蛙的约会 Time Limit:1000MS Memory Limit:10000KB 64bit IO Format:%lld & %llu Descr ...
- 数论初步(费马小定理) - Happy 2004
Description Consider a positive integer X,and let S be the sum of all positive integer divisors of 2 ...
随机推荐
- 7月12日至芯FPGA就业班招生
至芯科技FPGA就业培训班将于2014年7月12日正式开班,届时至芯科技将秉承着一贯的教学传统,为广大师生打造一个专业的技术平台和轻松的学习环境. 在夏宇闻教授的带领下,至芯科技汇聚了一批来自国内外大 ...
- 【HDOJ】2510 符号三角形
暴力打表. #include <cstdio> ]={,,,,,,,,,,,,,,,,,,,,,,,,}; int main() { while (scanf("%d" ...
- 【模拟】XMU 1599 斐波那契汤
题目链接: http://acm.xmu.edu.cn/JudgeOnline/problem.php?id=1599 题目大意: 给k,m,q以及f[1]...f[k],当n<m时,f[n]= ...
- SqlServer新建视图
一.使用SQL Server 2005数据库管理系统创建视图 1. 启动SQL Server 2005. 2. 在“对象资源管理器”窗口中找到Student数据库,打开Student文件夹,在“视图” ...
- datagridview的数据源的操作
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; usin ...
- 【转】Contrary to the answers here, you DON'T need to worry about encoding!
For those goals, I honestly do not understand why people keep telling you that you need the encoding ...
- hadoop 运行 datanode , mac 系统
问题描述 今天使用 hadoop 时,发现无法通过下面命令上传文件到 hadoop 文件系统,会报错. bin/hadoop fs -put input . 运行 jps 后,输出如下: Resour ...
- G - Oil Skimming - hdu 4185(二分图匹配)
题意:在大海里有一些石油 ‘#’表示石油, ‘.’表示水,有个人有一个工具可以回收这些石油,不过只能回收1*2大小的石油块,里面不能含有海水,要不就没办法使用了,求出来最多能回收多少块石油 分析:先把 ...
- 终于有人把O2O、C2C、B2B、B2C的区别讲透了
一.O2O.C2C.B2B.B2C的区别在哪里? o2o 是 online to offline 分为四种运营模式 1.online to offline 是线上交易到线下消费体验 2.offline ...
- 【Html 学习笔记】第三节——超链接
这一节看看超级链接的应用 普通超链接:<a href=""> <a> 第一个由于环境目前无法尝试,第二个点击后跳转到qq主页. 图片超链接:<imag ...