POJ 1426-Find The Multiple






#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <algorithm>
#include <queue>
#include <map>
#include <stack>
#include <vector>
#include <iostream>
using namespace std;

int main()
{
	int i,j,k; 
	
	int n;
	while(	scanf("%d",&n)!=EOF)
	{
		if (!n) break;
		int all=1<<19;
		for (j=all-1;j>=1;j--)
		{
			int tmp=j;
			string sum;
			for(i=1;i<=19;i++)
			{
				sum+='0'+tmp%2;
				tmp/=2;
			}
		 
			__int64 ans=0;
			for (i=sum.length()-1;i>=0;i--)
			{ 
				ans=ans*10+sum[i]-'0';
			}
			if (ans%n==0)
			{
				printf("%I64d\n",ans);
				break;
			}
		} 
		
	}
	return 0;
	
}


你可能感兴趣的:(POJ 1426-Find The Multiple)