This commit is contained in:
kyg516 2016-09-15 18:58:19 +09:00
parent b0102d255f
commit cdedb66e91
7 changed files with 7 additions and 336 deletions

View File

@ -24,7 +24,6 @@ class VolumeController < ApplicationController
else else
String state = (df.include? volume['Volume Name'].delete(' ')) ? "mounted" : "unmounted" String state = (df.include? volume['Volume Name'].delete(' ')) ? "mounted" : "unmounted"
volume['Mount State'] = state volume['Mount State'] = state
if state.eql? "mounted" if state.eql? "mounted"
s = df.split("\n") s = df.split("\n")
s.each do |t| s.each do |t|
@ -34,7 +33,6 @@ class VolumeController < ApplicationController
end end
end end
end end
@volumes << volume @volumes << volume
volume = Hash.new volume = Hash.new
end end
@ -70,21 +68,13 @@ class VolumeController < ApplicationController
end end
end end
mnt_dest = mnt_dir + "/" + file.original_filename mnt_dest = mnt_dir + "/" + file.original_filename
# change permission
puts "upload start" command = String.new
# get permission command << "sudo chmod 777 " + mnt_dir
# dir_left = mnt_dir[0..mnt_dir.rindex('/')] puts command
# dir_right = mnt_dir.split(dir_left)[1] `#{command}`
# pe = `ls -al #{dir_left} | grep #{dir_right}`.split(" ")[0]
# puts "111" + dir_left
# puts "222" + dir_right
# puts "333" + pe
u = AvatarUploader.new(mnt_dir) u = AvatarUploader.new(mnt_dir)
u.store!(file) u.store!(file)
puts "upload end"
redirect_to '/volume/index' redirect_to '/volume/index'
end end

View File

@ -11,14 +11,14 @@ class AvatarUploader < CarrierWave::Uploader::Base
# storage :fog # storage :fog
@path @path
def initialize(dest = "/mnt/dir") def initialize(dest)
super super
@path = dest @path = dest
end end
# Override the directory where uploaded files will be stored. # Override the directory where uploaded files will be stored.
# This is a sensible default for uploaders that are meant to be mounted: # This is a sensible default for uploaders that are meant to be mounted:
def cache_dir def store_dir
@path @path
end end

View File

@ -1,113 +0,0 @@
#include <iostream>
#include <cstdio>
#include <cstring>
#define min(a,b) ((a)<(b)?(a):(b))
using namespace std;
const int MAX_N = 6;
const int INF = 1e9;
const char interval[12][3]
= {"A", "A#", "B", "C", "C#", "D", "D#", "E", "F", "F#", "G", "G#"};
int n, m;
int str[MAX_N];
int tune[MAX_N];
int music[MAX_N];
int difficulty[MAX_N];
/*
6 3
E A D G B E
E G# B
6 3
E E B G# B E
E G# B
6 3
E E G# B A A
E G# B
6 3
E E G# B B A
E G# B
6 3
A A A A A A
E G# B
*/
int solve(int x)
{
if(x == n)
{
int cnt = 0;
bool chk[6] = {false};
for(int i = 0; i < n; ++i)
{
bool is_harmony = false;
for(int j = 0; j < m; ++j)
{
if(str[i] == music[j])
{
chk[j] = true;
is_harmony = true;
}
}
if(!is_harmony) return INF;
}
for(int i = 0; i < m; ++i)
if(!chk[i]) return INF;
int high = 0, low = INF;
for(int i = 0; i < n; ++i)
{
if(tune[i] == str[i]) continue;
++cnt;
int diff = min((tune[i] - str[i] + 12) % 12, (str[i] - tune[i] + 12) % 12);
if(high < diff) high = diff;
if(low > diff) low = diff;
}
if(!cnt) return 0;
if(cnt == 1) return high + 1;
return high - low + 1;
}
int ret = INF;
for(int i = 0; i < 12; ++i)
{
str[x] = i;
int tmp = solve(x + 1);
ret = min(ret, tmp);
}
return ret;
}
void get(int *cord)
{
char in[3]; cin >> in;
for(int i = 0; i < 12; ++i)
if(!strcmp(in, interval[i])) *cord = i;
}
void proc()
{
cin >> n >> m;
for(int i = 0; i < n; ++i) get(&tune[i]);
for(int i = 0; i < m; ++i) get(&music[i]);
if(!n || !m) {cout << 0; return;}
cout << solve(0) << "\n";
}
int main()
{
proc();
return 0;
}

View File

@ -1,113 +0,0 @@
#include <iostream>
#include <cstdio>
#include <cstring>
#define min(a,b) ((a)<(b)?(a):(b))
using namespace std;
const int MAX_N = 6;
const int INF = 1e9;
const char interval[12][3]
= {"A", "A#", "B", "C", "C#", "D", "D#", "E", "F", "F#", "G", "G#"};
int n, m;
int str[MAX_N];
int tune[MAX_N];
int music[MAX_N];
int difficulty[MAX_N];
/*
6 3
E A D G B E
E G# B
6 3
E E B G# B E
E G# B
6 3
E E G# B A A
E G# B
6 3
E E G# B B A
E G# B
6 3
A A A A A A
E G# B
*/
int solve(int x)
{
if(x == n)
{
int cnt = 0;
bool chk[6] = {false};
for(int i = 0; i < n; ++i)
{
bool is_harmony = false;
for(int j = 0; j < m; ++j)
{
if(str[i] == music[j])
{
chk[j] = true;
is_harmony = true;
}
}
if(!is_harmony) return INF;
}
for(int i = 0; i < m; ++i)
if(!chk[i]) return INF;
int high = 0, low = INF;
for(int i = 0; i < n; ++i)
{
if(tune[i] == str[i]) continue;
++cnt;
int diff = min((tune[i] - str[i] + 12) % 12, (str[i] - tune[i] + 12) % 12);
if(high < diff) high = diff;
if(low > diff) low = diff;
}
if(!cnt) return 0;
if(cnt == 1) return high + 1;
return high - low + 1;
}
int ret = INF;
for(int i = 0; i < 12; ++i)
{
str[x] = i;
int tmp = solve(x + 1);
ret = min(ret, tmp);
}
return ret;
}
void get(int *cord)
{
char in[3]; cin >> in;
for(int i = 0; i < 12; ++i)
if(!strcmp(in, interval[i])) *cord = i;
}
void proc()
{
cin >> n >> m;
for(int i = 0; i < n; ++i) get(&tune[i]);
for(int i = 0; i < m; ++i) get(&music[i]);
if(!n || !m) {cout << 0; return;}
cout << solve(0) << "\n";
}
int main()
{
proc();
return 0;
}

View File

@ -1,33 +0,0 @@
#include <cstdio>
#include <cstring>
#define max(a,b) ((a)<(b)?(b):(a))
int main()
{
int counter[10] = {0};
char number[100];
scanf("%s", number);
int len = strlen(number);
for(int i = 0; i <len; i++)
counter[number[i] - 48]++;
while(counter[6] < counter[9])
{
counter[6]++;
counter[9]--;
}
while(counter[9] < counter[6])
{
counter[6]--;
counter[9]++;
}
int sol = 0;
for(int i = 0; i < 10; i++)
if(sol < counter[i]) sol = counter[i];
printf("%d\n", sol);
}

View File

@ -1,60 +0,0 @@
#include <iostream>
#include <cstdio>
#include <queue>
#include <vector>
using namespace std;
const int MAX_N = 100;
const int INF = 1000000007;
const int dy[] = {0, 0, 1, -1};
const int dx[] = {1, -1, 0, 0};
int n, m;
char maze[MAX_N+2][MAX_N+2];
int dist[MAX_N+2][MAX_N+2];
int solve()
{
for(int i = 0; i < n; ++i)
for(int j = 0; j < m; ++j)
dist[i][j] = INF;
queue<pair<int, int> > q;
q.push(make_pair(0, 0));
dist[0][0] = 0;
while(!q.empty())
{
int y = q.front().first;
int x = q.front().second;
q.pop();
for(int i = 0; i < 4; ++i)
{
int ny = y + dy[i];
int nx = x + dx[i];
if(ny >= 0 && ny < n &&
nx >= 0 && nx < m &&
(dist[ny][nx] > dist[y][x] + (maze[ny][nx] == '1')))
{
dist[ny][nx] = dist[y][x] + (maze[ny][nx] == '1');
q.push(make_pair(ny, nx));
}
}
}
return dist[n - 1][m - 1];
}
void proc()
{
cin >> m >> n;
for(int i = 0; i < n; ++i)
cin >> maze[i];
cout << solve() << endl;
}
int main()
{
proc();
return 0;
}