fzu 1675 The Seventy-seven Problem
给你长度为 10^5~10^6长度,由数字组成的串 其中有4位不见了 补全该串 使得在该串能整除 77的同时 尽可能大
// 先计算出每个 n*10^m 模 77 的循环节 n=0,1,2..,9
// 然求出串的每位 mod 77 累加 抹黑的4为另外处理 #include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <string.h>
using namespace std;
#define maxm 100010
#define maxn 1000110
int rc[][];
int num[];
void calculate(int n){
int vi[]={};
int m=n;
int ct=;
rc[m][ct++]=m;
vi[n]=true;
while(){
n=n*;
n=n%;
if(vi[n]) break;
vi[n]=true;
rc[m][ct++]=n;
// printf("%d\n",n);
}
num[m]=ct;
}
char str[maxn];
int main()
{
int i,j,k,l;
int d[]={,,,,,,,,,,};
int a[];
for(i=;i<=;i++)
calculate(i);
num[]=;
// for(i=1;i<=9;printf("\n"),i++)
// for(j=0;j<num[i];j++)
// printf("%d ",rc[i][j]);
int tp;
// printf("%d\n",11167%77);
while(scanf("%s",str)!=EOF){
int len=strlen(str);
tp=j=;
for(i=;i<len;i++){
if(str[len-i-]!='x'){
k=str[len-i-]-'';
tp+=rc[k][i%num[k]];
}else{
a[++j]=i;
// printf("%d ",i);
}
}
// printf("%d\n",tp);
int lin;
int flag=;
for(i=;i<=;i++)
{
for(j=;j<=;j++)
{
for(k=;k<=;k++){
for(l=;l<=;l++){
lin=tp+rc[d[l]][a[]%num[d[l]]];
lin=lin+rc[d[k]][a[]%num[d[k]]];
lin=lin+rc[d[j]][a[]%num[d[j]]];
lin=lin+rc[d[i]][a[]%num[d[i]]];
if(lin%==) {flag=;break;}
}
if(!flag) break;
}
if(!flag) break;
}
if(!flag) break;
}
str[len-a[]-]=''+d[l];
str[len-a[]-]=''+d[k];
str[len-a[]-]=''+d[j];
str[len-a[]-]=''+d[i];
printf("%s\n",str); }
return ;
}
fzu 1675 The Seventy-seven Problem的更多相关文章
- FZU 2224 An exciting GCD problem(GCD种类预处理+树状数组维护)同hdu5869
题目链接:http://acm.fzu.edu.cn/problem.php?pid=2224 同hdu5869 //#pragma comment(linker, "/STACK:1024 ...
- FZU 2240 Daxia & Suneast's problem
博弈,$SG$函数,规律,线段树. 这个问题套路很明显,先找求出$SG$函数值是多少,然后异或起来,如果是$0$就后手赢,否则先手赢.修改操作和区间查询的话可以用线段树维护一下区间异或和. 数据那么大 ...
- FZU - 2038 -E - Another Postman Problem (思维+递归+回溯)
Chinese Postman Problem is a very famous hard problem in graph theory. The problem is to find a shor ...
- FZU 2238 Daxia & Wzc's problem
公式. $a×C_{m + i - 1}^m + d×C_{m + i - 1}^{m + 1}$. 推导过程可以看http://blog.csdn.net/queuelovestack/articl ...
- HITtrainning20140417题解
题目列表: ID Origin Title 10 / 15 Problem A FZU 2152 文件系统 0 / 16 Problem B FZU 2153 A simple geome ...
- (01背包 当容量特别大的时候) Knapsack problem (fzu 2214)
http://acm.fzu.edu.cn/problem.php?pid=2214 Problem Description Given a set of n items, each with a ...
- fzu Problem 2148 Moon Game(几何 凸四多边形 叉积)
题目:http://acm.fzu.edu.cn/problem.php?pid=2148 题意:给出n个点,判断可以组成多少个凸四边形. 思路: 因为n很小,所以直接暴力,判断是否为凸四边形的方法是 ...
- fzu Problem 2140 Forever 0.5(推理构造)
题目:http://acm.fzu.edu.cn/problem.php?pid=2140 题意: 题目大意:给出n,要求找出n个点,满足: 1)任意两点间的距离不超过1: 2)每个点与(0,0)点的 ...
- fzu 2037 Maximum Value Problem
http://acm.fzu.edu.cn/problem.php?pid=2037 思路:找规律,找出递推公式f[n]=f[n-1]*n+(n-1)!,另一个的结果也是一个递推,s[n]=s[n-1 ...
随机推荐
- 【C# 反射泛型】
C# 反射泛型 摘自:http://www.itwis.com/html/net/c/20110411/10175.html C#泛型反射和普通反射的区别,泛型反射和普通反射的区别就是泛型参数的处理上 ...
- HTML5 动画引擎 小记
国内: Cocos2d-x js版本 layabox Egret Sirius2D lufylegend.js Fireball 国外: CreateJS(EaselJS.TweenJS)http ...
- Unity3D IOS IPhone添加Admob的方法
原地址:http://dong2008hong.blog.163.com/blog/static/4696882720140403119293/ 首先阅读官方文档https://developers. ...
- POJ 2299 Ultra-QuickSort (排序+数据离散化+求顺序数)
题意:给出一个序列,求至少需要用到多少次操作,才能将序列从小到大排序. 思路: 数据量很大,n<500000,所以用冒泡模拟是超时的. 接下来就想到了求顺序数,总共需要交换的次数为每个数后面有多 ...
- SDUT1281Cup
http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=1281 题意 : 一个杯子,告诉你底面半径,顶端 ...
- hdu 1275 两车追及或相遇问题
思路:这里有2种情况: 一种是相遇:满足关系是 (va+vb)*t=L*(2*n-1) 一种是追及: 满足关系是 |va-vb|*t=L*(2*n-1) 这样求出2种情况的时间,在排序就可以了…… 链 ...
- Oracle 9 - redo和undo
1.redo redo 有在线redo日志和归档redo日志, 从Oracle 10g开始还新增加了flashback技术. 每个Oracle数据库至少有2个在线重做日志组,循环写. 只有INSERT ...
- lintcode :最小路径和
题目: 最小路径和 给定一个只含非负整数的m*n网格,找到一条从左上角到右下角的可以使数字和最小的路径. 样例 注意 你在同一时间只能向下或者向右移动一步 解题: 这个和求三角形的最小路径的差不多 ...
- ASP.NET获取路径的方法
原文:[转载]ASP.NET获取路径的方法 HttpContext.Current.Request.PhysicalPath; // 获得当前页面的完整物理路径.比如 F:\XFU.NSQS\p ...
- 33. Search in Rotated Sorted Array
题目: Suppose a sorted array is rotated at some pivot unknown to you beforehand. (i.e., 0 1 2 4 5 6 7 ...