This commit is contained in:
kyg516 2016-09-15 17:57:20 +09:00
parent 6e7f2dfdb7
commit bd8d968301
7 changed files with 341 additions and 5 deletions

View File

@ -72,8 +72,16 @@ class VolumeController < ApplicationController
mnt_dest = mnt_dir + "/" + file.original_filename
puts "upload start"
u = AvatarUploader.new
u.store_path(:dir)
# get permission
# dir_left = mnt_dir[0..mnt_dir.rindex('/')]
# dir_right = mnt_dir.split(dir_left)[1]
# 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.store!(file)
puts "upload end"

View File

@ -9,10 +9,17 @@ class AvatarUploader < CarrierWave::Uploader::Base
# Choose what kind of storage to use for this uploader:
storage :file
# storage :fog
@path
def initialize(dest = "/mnt/dir")
super
@path = dest
end
# Override the directory where uploaded files will be stored.
# This is a sensible default for uploaders that are meant to be mounted:
def store_dir
def cache_dir
@path
end
# Provide a default URL as a default if there hasn't been a file uploaded:

View File

@ -230,7 +230,10 @@
new_tr += "<td style='color:#0d8ade;' class='sorting_1'><i class='fa fa-folder-open-o'></i> ";
new_tr += "<a style='cursor: pointer' onclick='change_directory(" +'"' + cur + "/" + result.file[i].name +'"'+ ")'>" + result.file[i].name + "</a></td>";
new_tr += "<td>"+result.file[i].auth+"</td>";
new_tr += "<td><button class='btn btn-primary pull-right'>select</botton></td>";
new_tr += "<td><form data-parsley-validate>";
new_tr += "<input type='hidden' value='" + cur + "/" + result.file[i].name + "'>";
new_tr += "<button type='submit' class='btn btn-primary pull-right'>select</botton>";
new_tr += "</form></td>"
new_tr += "</tr>";
}
$("#datatable_body").append(new_tr);
@ -241,7 +244,6 @@
<!-- Mount overlay functions -->
<script>
$("#popup_mount #datatable_body form").submit(function(){
var mnt_point = $(this).find("input").val();
var url = window.location + '';
var vol_name = url.match(/volume_name=([^#]+)/)[1];
$.ajax({

View File

@ -0,0 +1,113 @@
#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

@ -0,0 +1,113 @@
#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

@ -0,0 +1,33 @@
#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

@ -0,0 +1,60 @@
#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;
}