14点开始做,现在时间16:23。出错了,头好晕~~~
来源:互联网 发布:碳晶地暖垫 知乎 编辑:程序博客网 时间:2024/04/30 15:01
头晕,算法已经想好,写出来的程序有漏洞,没有按照我的想法来执行。头晕!我做别的题目了。
我的程序代码:
/
*
Dramatic Multiplications
Time Limit:1000MS Memory Limit:65536K
Total Submit:714 Accepted:216
Description
Hassan, helping with his younger brother's homework, found out that when you multiply 102564 by 4, its right-most digit moves to the left, and the other digits move one position to the right; i.e. 4 * 102564 = 410256. We call a number that has this property when multiplied by n, an n-dramatic number. For instance, 102564 and 128205 are both 4-dramatic. Given two one-digit numbers n and k, the goal is to find the smallest n-dramatic number that its rightmost digit is k.
Input
On the first line of the input, there is an integer t, which is the number of cases that follow. Each test case, is on a line by itself, and contains two integers n and k, where 1 <= n <= 9, and 1 <= k <= 9.
Output
For each test case, output a single integer on a line by itself, which is the smallest n-dramatic number that its rightmost digit is k. If no such number exists, output 0 instead.
Sample Input
2
4 5
2 1
Sample Output
128205
0
Source
Tehran 2005
*/
#include "iostream"
using namespace std;
bool pandun(char *ch1,char * ch2)
{
int i=0,j=0,k,n;
while(ch1[i]!='a')
i++;
while(ch2[j]!='a')
j++;
n=j-2;
k=i-2;
if(ch1[0]==ch2[n+1])
{
while(1)
{
if(ch1[k]!=ch2[n])
{
return true;
}
k--;
n--;
if(k==1&&n==0)
return false;
}
}
else
return true;
}
int main()
{
int t,n,k,i,j,ch,flag;
char ch1[100],ch2[100],ch3[100];
cin>>t;
while(t)
{
cin>>n>>k;
i=0;
j=0;
flag=1;
memset(ch1,'a',sizeof(ch1));
memset(ch2,'a',sizeof(ch2));
memset(ch3,'0',sizeof(ch3));
ch1[j]=k+'0';
j++;
while(j<100)
{
ch=ch1[j-1]-'0';
ch*=n;
if(!(ch/10))
{
if((ch%10+ch3[i])>'9')
{
ch3[i+1]=(ch%10+ch3[i]-'0')/10+'0';
ch2[i]=(ch%10+ch3[i]-'0')%10+'0';
}
else
ch2[i]=(ch%10)+ch3[i];
i++;
}
else
{
if((ch%10+ch3[i])>'9')
{
ch3[i+1]=(ch%10+ch3[i]-'0')/10+'0';
ch2[i]=(ch%10+ch3[i]-'0')%10+'0';
}
else
ch2[i]=(ch%10)+ch3[i];
ch3[i+1]=ch/10+'0';
i++;
}
ch1[j]=ch2[i-1];
j++;
if(j==100)
flag=0;
}
if(/*(ch1[j-2]-'0')*n<10&&*/flag)
for(k=j-2;k>=0;k--)
cout<<ch1[k];
else
cout<<"0";
cout<<endl;
t--;
}
return 0;
}
- 14点开始做,现在时间16:23。出错了,头好晕~~~
- 现在开始做HSDPA了
- 现在开始做测试了
- 现在时间是23点3分,该休息了!
- 现在开始做测试
- 现在是可以为csdn做点什么的时候了
- 浪费了半年时间,开始做论文了
- 现在开始,做什么都不晚
- 学了有段时间了,只有做过笔记和云笔记,现在开始把学习和未来工作中遇到的好资料都保存到博客了.用了CSDN博客瞬间感觉自己Hacker了.哈哈
- 做了多年的开发,现在又要开始从新做人,两次流鼻血了。
- 现在开始学Java了 ~
- 我现在要开始了
- 现在开始写博客了
- 现在开始转做Android开发了,是用Eclipse好还是Android Studio好呢?
- (30 hackdays day 21) Wakatime - 现在几点了,你在做什么呢
- (30 hackdays day 21) Wakatime - 现在几点了,你在做什么呢
- 坚持做一件事从现在开始
- 开始做项目了
- 我为什么选palm,不选PPC(不是对用户的攻击哦)Zen of Palm
- SQL SERVER tips
- 找工作
- Castle研究-第一个Castle程序
- 关于权限管理的系统的构思
- 14点开始做,现在时间16:23。出错了,头好晕~~~
- 微软笔试题3
- 图片缓存BUG导致Ajax无效的解决
- FCKeditor與asp.net 7/24
- 看《北大牛人唐翔》有感以自勉
- Enum的toString方法
- Microsoft® Office Access 2003 Inside Out
- 高手的思路[ZT]
- Learn Windows XP In Pictures