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 torch | |
import torch.nn as nn | |
from torch.autograd import Variable | |
import torchvision.datasets as dset | |
import torchvision.transforms as transforms | |
import torch.nn.functional as F | |
import torch.optim as optim | |
## load mnist dataset | |
use_cuda = torch.cuda.is_available() |
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
/* | |
V2不能改内容所以直接这里改了: maxqueue的做法实际上是错误的; 这题并不需要这么复杂; | |
直接把dp算出来, 然后最后单独走一个min_step的循环, 找一个最大值就行了; | |
在算每一个dp[i]的时候, 不能包含这个反向min_step的循环的最大值. 只能最后返回之前算这个; | |
*/ | |
class Solution { | |
int solve (int[] staircase, int[] possible_steps) { | |
int min_step = Integer.MAX_VALUE, N = staircase.length; | |
for (int step : possible_steps) |
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 Solution { | |
int solve (int[] staircase, int[] possible_steps) { | |
int min_step = Integer.MAX_VALUE, N = staircase.length; | |
for (int step : possible_steps) | |
min_step = Math.min (min_step, step); | |
if (min_step > N) | |
return 0; | |
int[] dp = new int[N]; | |
for (int i = -1 + min_step; i < N; i++) { | |
int cur = Integer.MIN_VALUE; |
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 <stdio.h> | |
#include <stdlib.h> | |
static int N; | |
static int counter = 0; | |
static int do_io = 0; | |
static void helper (int idx, int pos, int* triplet); | |
int |