Sgu 119
|
119. Magic Pairs time limit per test: 0.25 sec. memory limit per test: 4096 KB 注意先%n能被n整除的ax+by那么d*ax+d*by也能因为a,b<n所以(d*ax+d*by)%n的也能被n整除,然后枚举! “Prove that for any integer X and Y if 5X+4Y is divided by 23 than 3X+7Y is divided by 23 too.” The task is from city Olympiad in mathematics in Saratov, Russia for schoolchildren of 8-th form. 2001-2002 year.
Input Each input consists of positive integer numbers N, A0 and B0 (N,A0,B0£ 10000) separated by whitespaces.
Output Write number of pairs (A, B) to the first line of output. Write each pair on a single line in order of non-descreasing A (and B in case of equal A). Separate numbers by single space.
Sample Input 3 1 2 Sample Output 3 0 0 1 2 2 1
1 #pragma comment(linker,"/STACK:102400000,102400000") 2 #include <cstdio> 3 #include <vector> 4 #include <cmath> 5 #include <queue> 6 #include <set> 7 #include <cstring> 8 #include <iostream> 9 #include <algorithm> 10 using namespace std; 11 #define INF 0x7fffffff 12 #define mod 1000000007 13 #define ll long long 14 #define maxn 200005 15 #define pi acos(-1.0) 16 #define dis(a, b) sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y)) 17 ll gcd(ll n, ll m){ return m ? gcd(m, n%m) : n; } 18 int n, m, k, c, a, b, x, y; 19 struct node{ 20 int a, b; 21 }p[maxn]; 22 bool cmp(node a, node b){ return (a.a < b.a || a.a == b.a&&a.b < b.b); } 23 int main(){ 24 scanf("%d%d%d", &n, &a, &b); 25 a %= n; b %= n;
|
||||||
|

浙公网安备 33010602011771号