Submission #3240597


Source Code Expand

package main

import (
	"bufio"
	"fmt"
	"io/ioutil"
	"os"
)

type IOTp struct {
	iBuffer []byte
	iPos int
}
func (this *IOTp) GetChar() byte {
	res:=this.iBuffer[this.iPos]
	this.iPos++
	return res
}
func (this *IOTp) ReadInt() int {
	res:=0
	k:=1
	for ch:=this.iBuffer[this.iPos]; !(ch>='0' && ch<='9'); ch=this.iBuffer[this.iPos]{
		if ch=='-' {
			k=-1
		}
		this.iPos++
	}
	for ch:=this.iBuffer[this.iPos]; ch>='0' && ch<='9'; ch=this.iBuffer[this.iPos]{
		res=res*10+int(ch-'0')
		this.iPos++
	}
	res*=k
	return res
}
func NewIOTp() *IOTp {
	now:=new(IOTp)
	//inputFile,_:=os.Open("in.txt")
	inputFile:=os.Stdin
	now.iBuffer,_=ioutil.ReadAll(inputFile)
	now.iBuffer=append(now.iBuffer, '\n')
	now.iPos=0
	return now
}
var cin *bufio.Reader
var cout *bufio.Writer
func max(a,b int) int {
	if a>=b {
		return a
	} else {
		return b
	}
}
func gcd(a,b int) int {
	for b!=0 {
		a,b=b,a%b
	}
	return a
}
func abs(x int) int {
	if x>=0 {
		return x
	} else {
		return -x
	}
}
func main() {
	IO:=NewIOTp()
	cout=bufio.NewWriter(os.Stdout)
	n,k:=IO.ReadInt(),IO.ReadInt()
	const MAXN=200000
	var a [MAXN+10]int
	for i:=1; i<=n; i++ {
		a[i]=IO.ReadInt()
	}
	x:=a[1]
	mx:=a[1]
	for i:=2; i<=n; i++ {
		x=gcd(x,a[i])
		mx=max(mx,a[i])
	}
	if k>mx {
		fmt.Println("IMPOSSIBLE")
		return
	}
	for i:=1; i<=n; i++ {
		if abs(a[i]-k)%x==0 {
			fmt.Println("POSSIBLE")
			return
		}
	}
	fmt.Println("IMPOSSIBLE")
	cout.Flush()
}

Submission Info

Submission Time
Task A - Getting Difference
User WAAutoMaton2
Language Go (1.6)
Score 300
Code Size 1510 Byte
Status AC
Exec Time 9 ms
Memory 4352 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 4
AC × 19
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt
All sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt, sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt, subtask_1_01.txt, subtask_1_02.txt, subtask_1_03.txt, subtask_1_04.txt, subtask_1_05.txt, subtask_1_06.txt, subtask_1_07.txt, subtask_1_08.txt, subtask_1_09.txt, subtask_1_10.txt, subtask_1_11.txt
Case Name Status Exec Time Memory
sample_01.txt AC 2 ms 2176 KB
sample_02.txt AC 2 ms 2176 KB
sample_03.txt AC 2 ms 2176 KB
sample_04.txt AC 2 ms 2176 KB
subtask_1_01.txt AC 2 ms 2176 KB
subtask_1_02.txt AC 2 ms 2176 KB
subtask_1_03.txt AC 9 ms 4352 KB
subtask_1_04.txt AC 7 ms 4352 KB
subtask_1_05.txt AC 5 ms 4352 KB
subtask_1_06.txt AC 3 ms 2688 KB
subtask_1_07.txt AC 7 ms 4352 KB
subtask_1_08.txt AC 8 ms 4352 KB
subtask_1_09.txt AC 5 ms 3328 KB
subtask_1_10.txt AC 8 ms 4352 KB
subtask_1_11.txt AC 8 ms 4352 KB