Skip to content

Instantly share code, notes, and snippets.

View nukopy's full-sized avatar

Yosuke Okuwaki nukopy

  • Tokyo, Japan
  • 13:30 (UTC +09:00)
View GitHub Profile
@nukopy
nukopy / dict2json.py
Created August 30, 2018 15:36
Generate JSON file from Python-dict: Convert dict-variables to JSON file
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import json
"""
explanation of json-module
json.load(file_obj) : file_obj --> dict
json.loads(json_str) : json_str --> dict
json.dumps(dict) : dict --> json_str
@nukopy
nukopy / load_json_to_dict.py
Created August 30, 2018 15:47
Convert JSON file to Python dict
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import json
"""
explanation of json-module
json.load(file_obj) : file_obj --> dict
json.loads(json_str) : json_str --> dict
json.dumps(dict) : dict --> json_str
@nukopy
nukopy / abc060b.cpp
Created November 26, 2018 07:11
ABC060 B - Choice Intergers
#include <iostream>
using namespace std;
int main() {
int A, B, C;
cin >> A >> B >> C;
for (int i = 1; i <= B; ++i) {
if (A*i%B == C) {
cout << "YES" << "\n";
@nukopy
nukopy / padding.cpp
Created January 2, 2019 07:58
Padding with STL, "ios", "iomanip" on C++.
// 左埋めパディング
// 必用なヘッダーインクルード
#include <ios> // std::left, std::right
#include <iomanip> // std::setw(int), std::setfill(char)
// macro 直後の要素をパディング
#define zero_pad(num) setfill('0') << std::right << setw(num)
#define space_pad(num) setfill(' ') << std::right << setw(num)
// std::left とすれば,右に '0' を埋めることができる
@nukopy
nukopy / abc026b.cpp
Created January 2, 2019 15:34
ABC026: B - N重丸
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <iterator> // std::back_inserter()
#include <set>
#include <map>
#include <algorithm> // std::copy()
#include <functional> // std::greater<T>()
#include <utility> // std::swap()
@nukopy
nukopy / abc027b.cpp
Created January 3, 2019 11:00
ABC027: B - 島と橋
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <iterator> // std::back_inserter()
#include <set>
#include <map>
#include <algorithm> // std::copy()
#include <functional> // std::greater<T>()
#include <utility> // std::swap()
@nukopy
nukopy / abc046b.cpp
Created January 4, 2019 12:55
ABC046: B - AtCoDeerくんとボール色塗り / Painting Balls with AtCoDeer
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <iterator> // std::back_inserter()
#include <set>
#include <map>
#include <algorithm> // std::copy()
#include <functional> // std::greater<T>()
#include <utility> // std::swap()
@nukopy
nukopy / abc017b.cpp
Created January 4, 2019 14:09
ABC017: B - choku語
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <iterator> // std::back_inserter()
#include <set>
#include <map>
#include <algorithm> // std::copy()
#include <functional> // std::greater<T>()
#include <utility> // std::swap()
@nukopy
nukopy / bitset_sstream.cpp
Created January 4, 2019 14:55
decimal to binary string.
#include <iostream>
#include <string>
#include <bitset> // static_cast<std::bitset<8>>
#include <sstream> // std::stringstream
using namespace std;
int main() {
int num = 55;
stringstream ss;
ss << std::bitset<8>(num);
@nukopy
nukopy / abc014b.cpp
Created January 4, 2019 15:20
ABC014: B - 価格の合計
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <iterator> // std::back_inserter()
#include <set>
#include <map>
#include <algorithm> // std::copy()
#include <functional> // std::greater<T>()
#include <utility> // std::swap()