結果
| 問題 | 
                            No.849 yuki国の分割統治
                             | 
                    
| コンテスト | |
| ユーザー | 
                             i_mrhj
                         | 
                    
| 提出日時 | 2019-08-08 12:30:05 | 
| 言語 | C  (gcc 13.3.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 1,371 bytes | 
| コンパイル時間 | 182 ms | 
| コンパイル使用メモリ | 32,256 KB | 
| 実行使用メモリ | 5,248 KB | 
| 最終ジャッジ日時 | 2024-10-07 03:06:14 | 
| 合計ジャッジ時間 | 2,860 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge4 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | WA * 4 | 
| other | WA * 26 | 
ソースコード
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <math.h>
#include <limits.h>
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) > (b) ? (b) : (a))
#define abs(x) ((x) > 0 ? (x) : -(x))
#define rep(i, n) for(int i = 0; i < (n); i++)
#define INF 1000000000000 //10^12
#define MOD 1000000007 //10^9 + 7
#define endl printf("\n")
typedef long long ll;
typedef struct { ll x, y; } R;
ll
rem(ll a, ll b)
{
  if (a < 0 && a % b < 0) return a % b + b;
  return a % b;
}
int
Rsort(const void *a, const void *b)
{
  R A = *(R *)a, B = *(R *)b;
  if (A.x == B.x && A.y == B.y) return  0;
  if (A.x < B.x) return -1;
  if (A.x > B.x) return  1;
  if (A.y < B.y) return -1;
  return 1;
}
int
main(int argc, char **argv)
{
  ll a, b, c, d;
  scanf("%lld %lld %lld %lld", &a, &b, &c, &d);
  
  int n;
  scanf("%d", &n);
  
  if (a * d - b * c != 0) {
    ll p = abs(a * d - b * c);
    ll x, y;
    R r[100000];
    for (int i = 0; i < n; i++) {
      scanf("%lld %lld", &x, &y);
      r[i].x = rem(d * x - c * y, p);
      r[i].y = rem(a * y - b * x, p);
      printf("%lld %lld\n", r[i].x, r[i].y);
    }
    
    qsort(r, n, sizeof(R), Rsort);
    int cnt = 1;
    for (int i = 0; i < n - 1; i++) {
      if (r[i].x != r[i + 1].x || r[i].y != r[i + 1].y) cnt++;
    }
    printf("%d\n", cnt);
  }
  return 0;
}
    
  
            
            
            
        
            
i_mrhj