11490: Just Another Problem

4
1 11490: Just Another Problem ★★★☆☆ 題題Problem Set Archive with Online Judge 題題11490: Just Another Problem 題題題蔡蔡蔡 題題題題2008 蔡 10 蔡 13 蔡

description

11490: Just Another Problem. ★★★☆☆ 題組: Problem Set Archive with Online Judge 題號: 1 1490: Just Another Problem 解題者: 蔡權昱 解題日期: 200 8 年 10 月 13 日. - PowerPoint PPT Presentation

Transcript of 11490: Just Another Problem

Page 1: 11490: Just Another Problem

1

11490: Just Another Problem ★★★☆☆ 題組: Problem Set Archive with Online Judge 題號: 11490: Just Another Problem 解題者:蔡權昱 解題日期: 2008 年 10 月 13日

Page 2: 11490: Just Another Problem

2

題意:假設有 96個士兵排排站 , 但是仔細數過後發現 , 只要再補8 個人就可以湊成一長方形 ( 如右圖 ),題目會給你 S, 問你還要多少人才可以湊成長方形 .限制 :1.只能把人補在中間 , 且必須補成兩個等大的正方形 . 所以補的人數限制為 2 * n2

2.在還沒補人之前的隊形 , 必須每個地方的寬度都相同 . 如圖箭頭寬度皆為 t.Ps. 輸出請 modulo 100000007

Page 3: 11490: Just Another Problem

3

題意範例:Sample input 96102111000 Sample outputPossible Missing Soldiers = 8

No Solution Possible

Possible Missing Soldiers = 553352Possible Missing Soldiers = 308898Possible Missing Soldiers = 45000Possible Missing Soldiers = 3528

Page 4: 11490: Just Another Problem

4

解法: math另 N=2*n2, 固定寬度為 t依題意可知 , S+N = (2t+n) * (3t+2n)=> S+2*n2 = 6t2 +7*t*n + 2*n2

=> S = 6t2 +7*t*n (S,t,n皆為正整數 )=> S | t

固可先將 S質因數分解 , 再由 S的因數去求 n. 解法範例:

96 => 可能的 t 為 1, 2, 3, 4, 6, 8, 12, 16, 24, 32, 48, 96令 t= 3代入 , 得 n=2, 答 2*22 = 8