Skip to content

Instantly share code, notes, and snippets.

@amoshyc
amoshyc / poj1759.md
Created August 27, 2015 16:16
Poj 1759: Garland

Poj 1759: Garland

分析

我本來想對 B 二分搜,然後反推 H2,之後計算出其它項… 我也真的這麼做了,跑去推 Hi 的通式,但發現 Hi 的通式中含有 (1 + sqrt(8)) ^ i 這種東西…這根本不能用啊

@amoshyc
amoshyc / poj3484.md
Last active August 29, 2015 06:07
Poj 3484: ShowStopper

Poj 3484: ShowStopper

分析

這題不太容易看出來是二分搜…倒是更讓人想到利用 xor。這題另一個難點是 IO , 據說卡 cin/cout,還有這題的題目也不易讀懂啊。

@amoshyc
amoshyc / OJBasicInput.cpp
Last active August 29, 2015 14:00
OJBasicInput.cpp
/*
這本來的某考上大學的非資訊社同學問我的,剛好有空就把它整理出來
以下是一些我臨時想到的,歡迎補充。
這些對論壇中大部人已經是基礎了吧~不過我想對下一屆學弟還是有用的。
我自己是習慣用 cin 和 string 來做 input,雖然有些題目真的需要用 scanf 速度上才過得了…
但 scanf 跟我不是很熟,怕誤導學弟,就等其它人來寫了。
以下都以例子來說明。
註:這些寫法不是唯一的,存在著許多不同寫法可以有同樣效果。
目錄:
@amoshyc
amoshyc / nthuoj10096.cpp
Created October 2, 2014 02:41
nthuoj10096.cpp
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <iomanip>
using namespace std;
int build_num(const string s, int* map) {
if (s.length() == 3)
@amoshyc
amoshyc / ezaddr.c
Created October 9, 2014 10:25
DS project 1: ezaddr.c
/*
Yu-Cheng Huang 09.24.2014 403410034
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
int max(const int a, const int b) {
return ((a > b) ? a : b);
@amoshyc
amoshyc / sortcomp.c
Last active August 29, 2015 14:07
DS project 2: sortcomp.c
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
#include <getopt.h>
#include <stdbool.h>
int int_data[1000000];
char* str_data[1000000];
void* temp[1000000];
@amoshyc
amoshyc / uva_tutorial.c
Last active August 29, 2015 14:07
uva_tutorial.c
/*
我想應該很多人寫 uva 時會遇到很多問題,所以我就寫了些教學。
這只是較常見的輸入型式,還存在其它複雜許多的,但大一應該碰不到,我就不一一論述了,有遇到問題的可以問我。
目錄:
0. uva 講解。
1. 單筆測資
2. 有給定測資數
3. 多筆測資:單行
4. 多筆測資:多行 1
@amoshyc
amoshyc / repeated_num.c
Last active August 29, 2015 14:07
repeated_num.c
/*
要求:
單筆測資,輸入為一個正整數(保證 int 可存),請輸出這個整數出現次數 2 次以上的數字,並輸出出現的次數。
若沒有任何數字出現 2 次以上,請輸出 "No repeated digit"。
# Sample Input 1
233345
# Sample Output 1
3: 3
# Sample Input 2
12345
@amoshyc
amoshyc / max_of_array.c
Last active August 29, 2015 14:07
max_of_array.c
/*
上個教學中使用 flag 的那種技巧是非常非常頻繁地使用的,以下舉幾個簡單例子。
*/
/*
題目 1:
單筆測資,給你一個長度為 10 的序列,序列中的每一項都是正整數(保證 int 可存),請輸出序列中的最大值。
# Sample Input
6 5 4 8 9 3 2 1 7 0
# Sample Output
@amoshyc
amoshyc / simplegrep.c
Last active August 29, 2015 14:08
DS project 3: simplegrep.c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <ctype.h>
#include <time.h>
#include <dirent.h>
#include <unistd.h>
#include <getopt.h>