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 ...
随机推荐
- PE文件结构详解(四)PE导入表
PE文件结构详解(二)可执行文件头的最后展示了一个数组,PE文件结构详解(三)PE导出表中解释了其中第一项的格式,本篇文章来揭示这个数组中的第二项:IMAGE_DIRECTORY_ENTRY_IMPO ...
- Unity3D Development模式下的一个小问题
今天客户提交了一个反馈,说测试版本的应用在按下电源键的时候屏幕变黑,然后重新按下电源键启动的时候发现没有出现屏幕锁屏的情况,直接回到应用界面. 我这边看了一下,发现如果装了360之类的手机助手就没这个 ...
- Unity3D 集合插件目录
http://unity3d.9ria.com/?p=2171 这个基本上很全 下面自己觉的还不错的,当然那些大众的就不列出来了 一.KGFMapSystem Quick Start : http:/ ...
- ****Git 常用命令和使用思维导图
Git 是一个很强大的分布式版本控制系统.它不但适用于管理大型开源软件的源代码,管理私人的文档和源代码也有很多优势. 本来想着只把最有用.最常用的 Git 命令记下来,但是总觉得这个也挺有用.那个也用 ...
- hdu1874 畅通工程续
http://acm.hdu.edu.cn/showproblem.php?pid=1874 //标准最短路模板 //需要注意的是两点间可能有多组 //需要取最短的 #include<iostr ...
- 1829 A Bug's Life
A Bug's Life Time Limit: 15000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Tot ...
- lintcode 中等题: reverse linked list II 翻转链表II
题目 翻转链表 II 翻转链表中第m个节点到第n个节点的部分 样例 给出链表1->2->3->4->5->null, m = 2 和n = 4,返回1->4-> ...
- 为什么重写equals方法还要重写hashcode方法?
我们都知道Java语言是完全面向对象的,在java中,所有的对象都是继承于Object类.Ojbect类中有两个方法equals.hashCode,这两个方法都是用来比较两个对象是否相等的. 在未重写 ...
- 258. Add Digits
题目: Given a non-negative integer num, repeatedly add all its digits until the result has only one di ...
- 248. Strobogrammatic Number III
题目: A strobogrammatic number is a number that looks the same when rotated 180 degrees (looked at ups ...