Rumah > pangkalan data > tutorial mysql > SRM 599 DIV2 500p

SRM 599 DIV2 500p

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Lepaskan: 2016-06-07 15:14:46
asal
1253 orang telah melayarinya

Problem Statement This problem statement contains superscipts that may not display properly outside the applet. You are given four ints A , B , C and D . Return divisible (quotes for clarity) if A B is divisible by C D . Return not divisib

Problem Statement

 

This problem statement contains superscipts that may not display properly outside the applet.


You are given four ints A, B, C and D. Return "divisible" (quotes for clarity) if AB is divisible by CD. Return "not divisible" otherwise.

Definition

 
Class: BigFatInteger2
Method: isDivisible
Parameters: int, int, int, int
Returns: string
Method signature: string isDivisible(int A, int B, int C, int D)
(be sure your method is public)
 
 

Notes

- The return value is case-sensitive.
- Positive integer y divides a positive integer x if and only if there is a positive integer z such that y*z=x. In particular, for each positive integer x, both 1 and x divide x.

Constraints

- A, B, C and D will each be between 1 and 1,000,000,000 (109), inclusive.

Examples

0)  
 
6
Salin selepas log masuk
Salin selepas log masuk
1
Salin selepas log masuk
Salin selepas log masuk
Salin selepas log masuk
Salin selepas log masuk
Salin selepas log masuk
Salin selepas log masuk
2
Salin selepas log masuk
Salin selepas log masuk
Salin selepas log masuk
Salin selepas log masuk
1
Salin selepas log masuk
Salin selepas log masuk
Salin selepas log masuk
Salin selepas log masuk
Salin selepas log masuk
Salin selepas log masuk
Returns: "divisible"
Salin selepas log masuk
Salin selepas log masuk
Salin selepas log masuk
Here, AB = 61 = 6 and CD = 21 = 2. 6 is divisible by 2.
1)  
 
2
Salin selepas log masuk
Salin selepas log masuk
Salin selepas log masuk
Salin selepas log masuk
1
Salin selepas log masuk
Salin selepas log masuk
Salin selepas log masuk
Salin selepas log masuk
Salin selepas log masuk
Salin selepas log masuk
6
Salin selepas log masuk
Salin selepas log masuk
1
Salin selepas log masuk
Salin selepas log masuk
Salin selepas log masuk
Salin selepas log masuk
Salin selepas log masuk
Salin selepas log masuk
Returns: "not divisible"
Salin selepas log masuk
Salin selepas log masuk
Salin selepas log masuk
2 is not divisible by 6.
2)  
 
1000000000
Salin selepas log masuk
Salin selepas log masuk
Salin selepas log masuk
Salin selepas log masuk
1000000000
Salin selepas log masuk
Salin selepas log masuk
Salin selepas log masuk
Salin selepas log masuk
1000000000
Salin selepas log masuk
Salin selepas log masuk
Salin selepas log masuk
Salin selepas log masuk
200000000
Salin selepas log masuk
Returns: "divisible"
Salin selepas log masuk
Salin selepas log masuk
Salin selepas log masuk
Now the numbers are huge, but we can see that AB is divisible by CD from the fact that A=C and B>D.
3)  
 
8
Salin selepas log masuk
100
Salin selepas log masuk
4
Salin selepas log masuk
Salin selepas log masuk
200
Salin selepas log masuk
Returns: "not divisible"
Salin selepas log masuk
Salin selepas log masuk
Salin selepas log masuk
We can rewrite 8100 as (23)100 = 2300. Similarly, 4200 = (22)200 = 2400. Thus, 8100 is not divisible by 4200.
4)  
 
999999937
Salin selepas log masuk
1000000000
Salin selepas log masuk
Salin selepas log masuk
Salin selepas log masuk
Salin selepas log masuk
999999929
Salin selepas log masuk
1
Salin selepas log masuk
Salin selepas log masuk
Salin selepas log masuk
Salin selepas log masuk
Salin selepas log masuk
Salin selepas log masuk
Returns: "not divisible"
Salin selepas log masuk
Salin selepas log masuk
Salin selepas log masuk
Here A and C are distinct prime numbers, which means AB cannot have C as its divisor.
5)  
 
2
Salin selepas log masuk
Salin selepas log masuk
Salin selepas log masuk
Salin selepas log masuk
2
Salin selepas log masuk
Salin selepas log masuk
Salin selepas log masuk
Salin selepas log masuk
4
Salin selepas log masuk
Salin selepas log masuk
1
Salin selepas log masuk
Salin selepas log masuk
Salin selepas log masuk
Salin selepas log masuk
Salin selepas log masuk
Salin selepas log masuk
Returns: "divisible"
Salin selepas log masuk
Salin selepas log masuk
Salin selepas log masuk

This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2003, TopCoder, Inc. All rights reserved.     

分解质因数。。。。

注意A或C可能是质数。。。。

#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>

using namespace std;

class BigFatInteger2 {
public:
string isDivisible(int, int, int, int);
};

typedef long long ll;
ll gcd(ll a,ll b)
{return b==0?a:gcd(b,a%b);}
bool isp(int n)
{
    if(n==2)return 1;
    if(n%2==0)return 0;
    for(int i=3;i pa,pc;
string BigFatInteger2::isDivisible(int A, int B, int C, int D)
{
    string div("divisible"),nodiv("not divisible");

    ll a,b,c,d;
    a=A,b=B,c=C,d=D;
	int ta=sqrt(A),tc=sqrt(C);
    for(int i=2;i
//Powered by [KawigiEdit] 2.0!
</ctime></cstdlib></cmath></cstdio></iomanip></iostream></sstream></utility></numeric></functional></algorithm></bitset></stack></deque></set></map></list></vector>
Salin selepas log masuk


Label berkaitan:
sumber:php.cn
Kenyataan Laman Web ini
Kandungan artikel ini disumbangkan secara sukarela oleh netizen, dan hak cipta adalah milik pengarang asal. Laman web ini tidak memikul tanggungjawab undang-undang yang sepadan. Jika anda menemui sebarang kandungan yang disyaki plagiarisme atau pelanggaran, sila hubungi admin@php.cn
Tutorial Popular
Lagi>
Muat turun terkini
Lagi>
kesan web
Kod sumber laman web
Bahan laman web
Templat hujung hadapan