This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef __MYLIB_H | |
#define __MYLIB_H | |
#include<iostream> | |
#include<vector> | |
#include<stack> | |
#include<algorithm> | |
#include<cstdio> | |
#include<cstring> | |
#include<climits> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
syntax = "proto2"; | |
package model; | |
message Person { | |
required string name = 1; | |
required int32 id = 2; | |
optional string email = 3; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package sample; | |
import model.Model.*; | |
import java.io.*; | |
public class ProtocolBufferSample { | |
private static String DATA_SOURCE; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<project xmlns="http://maven.apache.org/POM/4.0.0" | |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | |
<modelVersion>4.0.0</modelVersion> | |
<groupId>protocol.buffer</groupId> | |
<artifactId>sample</artifactId> | |
<version>1.0-SNAPSHOT</version> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import lombok.Data; | |
public @Data class Student { | |
String name; | |
String address; | |
int age; | |
double gpa; | |
} | |
// javac -cp lombok.jar Student.java -> That's not too much right? ;) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Student { | |
String name; | |
String address; | |
int age; | |
double gpa; | |
public String getName() { | |
return name; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <vector> | |
#include <algorithm> | |
#include <cstdio> | |
#include <cmath> | |
#include <queue> | |
#include <cstring> | |
#include <map> | |
#include <climits> | |
#include <set> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MaxTriangle { | |
public: | |
double calculateArea(int a, int b) { | |
vector<pair<int, int> > va = getVectors(a); | |
vector<pair<int, int> > vb = getVectors(b); | |
double ret = -2; | |
for(int i = 0; i < sz(va); i++) { | |
for(int j = 0; j < sz(vb); j++) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
vector<pair<int, int> > getVectors(int x) { | |
vector<pair<int, int> > ret; | |
for(int i = 0; i*i <= x; i++) { | |
int y = sqrt(x-i*i); | |
if(i*i+y*y == x) { | |
ret.push_back(make_pair(i, y)); | |
ret.push_back(make_pair(-i, y)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define LINE_WIDTH_TOO_SMALL -1 | |
vector<string> split(string text) { | |
vector<string> ret; | |
int cur = 0; | |
for(int i = 0; i < text.size(); i++) { | |
if(text[i] == ' ' || text[i] == '\n') { | |
ret.push_back(text.substr(cur, i-cur)); | |
cur = i+1; |