OI Progress
Posted on 六月 10th, 2008.
可以发现,一个数平方的最后9位只和这个数的最后9位有关.对1~9位数随便写个小程序枚举一下,就可发现:对于1位数到8位数,没有任何符合条件;对于9位数,有8个数符合条件;对于n位数(n>9),最高位有9种(1~9),后9位有8种,剩余n-10位每位10种(0~9),总共72*10^(n-10)种.
{SGU 107; 987654321 Problem- sqybi’s code}//for my winstyprogram sgu107_sqybi; var i, n: longint;
begin readln(n); if n <= 8 then writeln(0) else if n = 9 then writeln(8) else begin write(72); for i:=1 to n-10 do write(0); end; end.
阅读(76 次)
Read Full Post |
Make a Comment ( None so far )
Posted on 六月 8th, 2008.
找到最靠后的一个满足它左边的’(’比’)’数量多的’(’,改成’)’,然后在后面补(…()…)和)…).好久以前就写过的题.刚才写错了一点,在最后填括号的时候先填(…()…),再填)…).
{ SGU 179; Brackets light - sqybi’s code}//for my winstyprogram sgu179_sqybi; var i, l, r, tr, t: longint; s: ansistring;
begin readln(s); l := length(s); t := 0; r := 0; for i:=1 to l do begin if (t > 0) and (s[i] = ‘(’) then begin tr := t; r := i; end; […]
Read Full Post |
Make a Comment ( None so far )
Posted on 五月 27th, 2008.
这道题WindyWinter牛给出的算法是并查集,实际上可以DFS解决(感谢alft…).
每个人选的两个课程之间连无向边,然后DFS时进行黑白染色,DFS树上每个结点和他的父亲节点不同色.然后考虑横向边和返祖边,如果有一条边两边的结点颜色相同则说明无解,否则将白色的考试放在一天,黑色的放在另一天就可以了…并查集当然也没错…
注意会是一个森林,需要多次DFS…
{ SGU 172; eXam - sqybi’s code - DFS}//for my winstyprogram sgu172_sqybi; const nn = 200; mm = 30000;
var n, m, tot, i, x, y, t: longint; flag: boolean; head, p: array[1..nn]of longint; adj, next: array[-mm..mm]of longint;
procedure addEdge(x, y: longint); begin inc(tot); adj[tot] := y; next[tot] := head[x]; head[x] := tot; […]
Read Full Post |
Make a Comment ( None so far )
Posted on 五月 25th, 2008.
其实真的不难…自己找一下规律吧.因为有mod m嘛…然后就几个一循环而已…
{ SGU 181; X-Sequence - sqybi’s code}//for my winstyprogram sgu181_sqybi; const mm = 1000;
var n, i: longint; x, a, b, c, m, stop, r: int64; f, t: array[0..mm]of longint;
begin readln(x, a, b, c, m, n); if n = 0 then begin writeln(x); halt; end; fillchar(f, sizeof(f), 0); stop := 0; […]
Read Full Post |
Make a Comment ( 5 so far )
Posted on 五月 25th, 2008.
bt的数学题.题解看这里:http://www.mydrs.org/dvp/dispbbs.php?boardid=13&id=436842楼说的还算比较详细…我刚开始把题目里P的定义的乘法看成了加法所以一直不懂2楼说的,后来看题之后才发现自己看错了…
{ SGU 169; Numbers - sqybi’s code - Maths}//for my winstyprogram sgu169_sqybi; var n, t: longint;
begin readln(n); if n = 1 then writeln(8) else begin t := 1; if (n - 1) mod 3 = 0 then t := t + 2; if (n - 1) mod 6 = 0 then t := […]
Read Full Post |
Make a Comment ( None so far )
« Previous Entries Next Entries »