poj 2897 Dramatic Multiplications 模拟

//poj 2897
//sep9
#include<iostream>
using namespace std;
int ans[128],ansp;
int main()
{
	int cases,n,k;
	scanf("%d",&cases);
	while(cases--){
		memset(ans,0,sizeof(ans));
		ansp=0;
		scanf("%d%d",&n,&k);
		int flag=1,c=0,times=0;
		ans[ansp++]=k;
		while(1){
			int p=(n*k+c)%10;
			if(p==ans[0]&&(n*k+c)/10==0)
				break;
			ans[ansp++]=p;
			c=(n*k+c)/10;
			k=p;
			++times;
		}
		if(ans[ansp-1]==0)
			puts("0");
		else{
			for(int i=ansp-1;i>=0;--i)
				printf("%d",ans[i]);
			printf("\n");
		}

	}
	return 0;
}

时间: 2024-10-12 15:27:17

poj 2897 Dramatic Multiplications 模拟的相关文章

poj 3399 Product(模拟)

# include <stdio.h> # include <string.h> # include <algorithm> using namespace std; int cmp(int x,int y) { return x>y; } int main() { int a[110],a1[110],a2[110],ans[110]; int n,k,k1,k2,i,k3; while(~scanf("%d%d",&n,&k

poj 2632 Crashing Robots, 模拟

点击打开链接 简单 模拟机器人的移动,发生碰撞时输出相应的信息. code #include <cstdio> #include <cstring> using namespace std; struct node{ int k; int s; } mtx[200][200]; struct node1{ int x, y; } rob[200]; int n, m; int dir[4][2]= {{0,1},{1,0},{0,-1},{-1,0}}; //N, E, S, W

【POJ】 Instant Complexity (模拟)

[POJ] Instant Complexity (模拟) Instant Complexity Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 1905   Accepted: 657 Description Analyzing the run-time complexity of algorithms is an important tool for designing efficient programs that

POJ 2632 Crashing Robots (模拟 坐标调整)(fflush导致RE)

题目链接:http://poj.org/problem?id=2632 先话说昨天顺利1Y之后,直到今天下午才再出题 TAT,真是刷题计划深似海,从此AC是路人- - 本来2632是道稍微恶心点的模拟,但毕竟是模拟,一般模拟都是只要示例过了基本就AC了,但这个题很特殊 我开始的时候一直跑不出测试示例,才发现题目中的插图和我构想的坐标系是不一样的(看来还不能轻易忽视掉插图啊) 这个题给出的坐标系是纵轴为y,横轴为x,y从下到上依次递增,x轴是从左到右递增 而我用的二维数组记录的地图,也就是说我的纵

POJ 2897 Monkeys&#39; Pride 解题报告

Description Background There are a lot of monkeys in a mountain. Every one wants to be the monkey king. They keep arguing with each other about that for many years. It is your task to help them solve this problem. Problem Monkeys live in different pl

POJ 3030. Nasty Hacks 模拟水题

Nasty Hacks Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 13136   Accepted: 9077 Description You are the CEO of Nasty Hacks Inc., a company that creates small pieces of malicious software which teenagers may use to fool their friends.

HDU 1361 &amp; POJ 1068 Parencodings(模拟)

题目链接: HDU:http://acm.hdu.edu.cn/showproblem.php?pid=1361 POJ:http://poj.org/problem?id=1068 Description Let S = s1 s2...s2n be a well-formed string of parentheses. S can be encoded in two different ways: q By an integer sequence P = p1 p2...pn where

POJ 3295 Tautology (栈模拟)

Tautology Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 10096   Accepted: 3847 Description WFF 'N PROOF is a logic game played with dice. Each die has six faces representing some subset of the possible symbols K, A, N, C, E, p, q, r, s

POJ 1068 Parencodings (模拟),暑假第一题~

终于考完高线大,头也不那么疼了,也终于有空来刷题了~,先来一发水题试试水 题目链接:http://poj.org/problem?id=1068 简单的模拟,麻烦在理解题意,,英语好的请无视这句: [分析] S (((()()()))) P-sequence 4 5 6666 W-sequence 1 1 1456 如这个 S字符串, 题目给你一串数 4 5 6 6 6 6    对应P1 P2,,,Pn 意思是,第n个右括号')'左边有Pn 个左括号 ,,例如 456666 第1个右括号")&