Codeforces Beta Round #62
はい。
http://codeforces.com/contest/68
A. Irrational problem
implementation,number theory
ざっくりと大意
・p1,p2,p3,p4を4!の重複ありの組合せで式を作る。
・x=(((x%p1)%p2)%p3)%p4 の式が成立するのがa<=x<=bの範囲で幾つあるか?
方針のようなもの
・4!の組合せを試すはずだし、rambdaとかpermutationとか使ってキッチリ組合せ試してっぽい人いらっしゃるけどなぜか組合せ試さずAC出る。。。なんぞねコレ??
#!/usr/bin/env python # -*- coding: UTF-8 -*- import time import sys, io import re, math #start = time.clock() #n=int(raw_input()) #p1,p2,p3,p4,a,b=map(int,raw_input().split()) ans=0 l=[int(x) for x in raw_input().split()] for i in range(l[4],l[5]+1): if i%l[0]%l[1]%l[2]%l[3]==i: ans+=1 print ans
ただ今回の問題では組合せ試さずにACになったけど余裕があればそうなる(おそらく数学上の何か)理由とか、rambdaとかpermutation使ってる人のコードを読んでおいた方が良さそう。