結果
| 問題 |
No.1253 雀見椪
|
| コンテスト | |
| ユーザー |
keymoon
|
| 提出日時 | 2021-01-18 11:35:27 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 3,528 bytes |
| コンパイル時間 | 2,244 ms |
| コンパイル使用メモリ | 107,520 KB |
| 実行使用メモリ | 19,840 KB |
| 最終ジャッジ日時 | 2024-11-30 23:02:46 |
| 合計ジャッジ時間 | 2,937 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 3 RE * 11 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
public static class P
{
public static void Main()
{
int t = int.Parse(Console.ReadLine());
for (int i = 0; i < t; i++) Solve();
}
static void Solve()
{
var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
var n = input[0];
var gProb = (ModInt)input[1] / input[2];
var cProb = (ModInt)input[3] / input[4];
var pProb = (ModInt)input[5] / input[6];
var res = 1
- (Power(1 - gProb, n) - Power(cProb, n) - Power(pProb, n)) // グーが出されないが、チョキのみ/パーのみではない
- (Power(1 - cProb, n) - Power(gProb, n) - Power(pProb, n)) // チョキが出されないが、グーのみ/パーのみではない
- (Power(1 - pProb, n) - Power(gProb, n) - Power(cProb, n)); // パーが出されないが、グーのみ/チョキのみではない
Console.WriteLine(res);
}
static ModInt Power(ModInt n, long m)
{
ModInt pow = n;
ModInt res = 1;
while (m > 0)
{
if ((m & 1) == 1) res *= pow;
pow *= pow;
m >>= 1;
}
return res;
}
}
struct ModInt
{
public const int Mod = 1000000007;
const long POSITIVIZER = ((long)Mod) << 31;
long Data;
public ModInt(long data) { if ((Data = data % Mod) < 0) Data += Mod; }
public static implicit operator long(ModInt modInt) => modInt.Data;
public static implicit operator ModInt(long val) => new ModInt(val);
public static ModInt operator +(ModInt a, int b) => new ModInt() { Data = (a.Data + b + POSITIVIZER) % Mod };
public static ModInt operator +(ModInt a, long b) => new ModInt(a.Data + b);
public static ModInt operator +(ModInt a, ModInt b) { long res = a.Data + b.Data; return new ModInt() { Data = res >= Mod ? res - Mod : res }; }
public static ModInt operator -(ModInt a, int b) => new ModInt() { Data = (a.Data - b + POSITIVIZER) % Mod };
public static ModInt operator -(ModInt a, long b) => new ModInt(a.Data - b);
public static ModInt operator -(ModInt a, ModInt b) { long res = a.Data - b.Data; return new ModInt() { Data = res < 0 ? res + Mod : res }; }
public static ModInt operator *(ModInt a, int b) => new ModInt(a.Data * b);
public static ModInt operator *(ModInt a, long b) => a * new ModInt(b);
public static ModInt operator *(ModInt a, ModInt b) => new ModInt() { Data = a.Data * b.Data % Mod };
public static ModInt operator /(ModInt a, ModInt b) => new ModInt() { Data = a.Data * GetInverse(b) % Mod };
public static bool operator ==(ModInt a, ModInt b) => a.Data == b.Data;
public static bool operator !=(ModInt a, ModInt b) => a.Data != b.Data;
public override string ToString() => Data.ToString();
public override bool Equals(object obj) => (ModInt)obj == this;
public override int GetHashCode() => (int)Data;
static long GetInverse(long a)
{
long div, p = Mod, x1 = 1, y1 = 0, x2 = 0, y2 = 1;
while (true)
{
if (p == 1) return x2 + Mod; div = a / p; x1 -= x2 * div; y1 -= y2 * div; a %= p;
if (a == 1) return x1 + Mod; div = p / a; x2 -= x1 * div; y2 -= y1 * div; p %= a;
}
}
}
keymoon