2013 雅虎北研第一题:
#include <iostream>
using namespace std;
void fun(int a,int b,int m,int d)
{
int *q=new int[b-1];
a=a%b;
for(int i=0;i<b-1;i++)
{
q[i]=10*a/b;
a=10*a%b;
}
int count=1;
for(i=0;i<b-1;i++)
{
if(q[i]==d)
{
if(count==m)
{
cout<<i+1<<endl;
break;
}
count++;
}
}
delete q;
}
int main()
{
/* Enter your code here. Read input from STDIN. Print output to STDOUT */
int a,b,m,d;
int n;
cin>>n;
int *p=new int[4*n];
for(int i=0;i<n;i++)
{
cin>>a>>b>>m>>d;
p[4*i]=a;
p[4*i+1]=b;
p[4*i+2]=m;
p[4*i+3]=d;
}
for(i=0;i<n;i++)
{
fun(p[4*i],p[4*i+1],p[4*i+2],p[4*i+3]);
}
delete p;
return 0;
}